Replacing an id-less script by its synthetic location appends instead of replacing on the draft path

Aperta
#2,799 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Start in the writer's _upsert_top_level_list and compare its handling with require_instance, which already falls back to the parser's positional label for id-less component instances. Trace how synthetic script locations are resolved when no item has that id; done means replacing the parsed row positionally and returning a success diff without appending a duplicate.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

An id-less top level script: entry parses to a synthetic location (script_<index>), and _upsert_top_level_list matches list items by their id field, so a replace aimed at that synthetic id matches nothing and appends a duplicate instead. The guarded path (#2788, save or expected) refuses this after the fact; the editor's auto-apply path is unguarded by design (parse free per keystroke) and returns a success diff with the duplicate.

Fix belongs in the writer: resolve a synthetic script_<index> location positionally when no item carries that id, the way _require_instance already falls back to the parser's positional label for id-less component instances, so the replace lands on the row the parser listed.

Raised by esphbot on #2788.

Lingua principale
Python
Stelle
111
Fork
34
Merge medio
7h 59m
PR unite (30g)
135

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di esphome/device-builder

Tutte le issue di esphome/device-builder

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.