HTML close-tag auto-insertion (`onTypeFormatting` on `>`) closes the wrong element
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 38/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
- Ambito
- developer-experience
Direzione di ricerca
Start from HtmlElementAutoclosingOnTypeFormattingProvider, which handles textDocument/onTypeFormatting with ch >; reproduce with the <ul>\n <li>\n</ul> snippet and trace how the element lookup behaves when the tree parses into an error node. Read the earlier fix from PR #516 for context on Liquid branches. Note a linked open PR (#1328) already targets this issue, so check its status before starting; done means the response inserts </li> for the just-opened element in the error-state document.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
When I type > to finish an opening tag, the language server's textDocument/onTypeFormatting response inserts the closing tag of the parent element instead of the element I just opened. In my case the parent's closing tag already exists later in the document (the usual situation when adding a child to existing markup). I noticed it in Zed, but the wrong text comes from the server's response (see "Additional context").
Source
<ul>
</ul>
Steps: on the empty line, type <li>. The cursor is right after the >.
Expected behaviour
</li> is inserted after the cursor.
Actual behaviour
</ul> is inserted:
<ul>
<li></ul>
</ul>
The server then reports Attempting to close HtmlElement 'ul' before HtmlElement 'li' was closed on the inserted text.
Debugging information
- OS: Mac
- OS Version: 27.0.1
- Theme Check Version: n/a, I'm using the language server through the Zed Liquid extension, version 0.7.0
- Editor: Zed 1.22.0
Additional context
LSP trace. The trace below comes from a larger file (header.liquid), so the line and character numbers differ from the snippet above. The document at the time of the request (unclosed <li> followed by the existing </ul>):
<ul>
<li>
</ul>
Request:
{"jsonrpc":"2.0","id":46,"method":"textDocument/onTypeFormatting","params":{"textDocument":{"uri":"file:///.../header.liquid"},"position":{"line":17,"character":10},"ch":">","options":{"tabSize":2,"insertSpaces":true,"trimTrailingWhitespace":true,"insertFinalNewline":true,"trimFinalNewlines":true}}}
Response:
{"jsonrpc":"2.0","id":46,"result":[{"range":{"start":{"line":17,"character":10},"end":{"line":17,"character":10}},"newText":"</ul>"}]}
The position (line 17, character 10) is immediately after the > of <li>, so the request is well-formed. I reproduced it on two separate captures with the same result.
My guess, which may be wrong: at the time of the request the document doesn't parse, because <li> is unclosed before </ul> (the server reports a parse error for this document). The element lookup in HtmlElementAutoclosingOnTypeFormattingProvider seems to land on the parent when the tree is in that error state.
This looks related to the earlier fix "Fix HTML element close tag auto-insertion inside Liquid branches (#516)", but my case has no Liquid branches, only plain HTML.
Workaround: in Zed, setting "use_on_type_format": false for the HTML language stops the behavior. That confirms the insertion comes from this request. Inside a Liquid file, Zed treats the language at the cursor as HTML, so that setting applies there. Other features (completions, diagnostics, hover) work normally.
- Lingua principale
- TypeScript
- Stelle
- 237
- Fork
- 100
- Merge medio
- 18h 10m
- PR unite (30g)
- 16
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Shopify/theme-tools
-
theme-graph CLI never calls getWebComponentMap, so custom-element references are never resolvedForse già presa @reginaldalfret l’ha presa 15 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
Shopify/theme-tools#1291 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
JSONMissingBlock false positive for app block when section supports both @app and @themeForse già presa @chippleh1392 l’ha presa 132 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Shopify/theme-tools#1144 · 2 commenti · 8 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
theme-graph: parse failures silently produce an incomplete graph, causing false dead-code resultsForse già presa @efegokdemir l’ha presa 16 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
Shopify/theme-tools#1290 ·
I maintainer di solito rispondono entro 1 giorno
-
inserts extra ">" if: <label>text</label><textarea></textarea>Forse già presa @kwy404 l’ha presa 23 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
Shopify/theme-tools#1288 ·
I maintainer di solito rispondono entro 1 giorno
-
OrphanedSnippet: contextual templates (*.context.*.json) crash theme graph, flagging every snippet as orphanedForse già presa @OllieinCanada l’ha presa 56 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
Shopify/theme-tools#1279 · 1 commento · 3 reazioni ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Shopify/theme-tools
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
ccch1mneyyy/dsh-TUI#1631 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
MiniMax-AI/minimax-code#507 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Transient OAuth login failure persists in getLoginStatus and masks active account in dashboardForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertaaccount-pool bug gui
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
lidge-jun/opencodex#7378 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Admin search throws for permissions added through Admin.generalIndexItems('permissions', ...)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno