feat: add textDocument/_vs_onAutoInsert handler for VS closing tag auto-insertion#3436
feat: add textDocument/_vs_onAutoInsert handler for VS closing tag auto-insertion#3436lucygramley wants to merge 12 commits intomicrosoft:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds Visual Studio–specific support for automatic closing-tag insertion via the textDocument/_vs_onAutoInsert LSP request, integrating it with the existing JSX closing-tag completion logic and updating lsproto codegen to support overridden JSON field names.
Changes:
- Register and implement
textDocument/_vs_onAutoInsertrequest handling in the LSP server and advertise the_vs_onAutoInsertProvidercapability with_vs_triggerCharacters. - Extend lsproto with VS-specific protocol types and
_vs_-prefixed JSON field mappings. - Update JSX closing-tag completion to provide VS-formatted snippet
TextEditdata and enhance fourslash baseline range selection accordingly. - Fix lsproto code generator to respect per-property
jsonNameoverrides in JSON tags and unmarshal switch cases.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/lsp/server.go | Registers the new VS auto-insert request, advertises capability, and implements the handler delegating to closing-tag completion. |
| internal/lsp/lsproto/lsp_generated.go | Adds new protocol capability/types/method wiring and VS-prefixed JSON fields in generated protocol code. |
| internal/lsp/lsproto/_generate/metaModelSchema.mts | Extends the meta-model schema to allow a jsonName override per property. |
| internal/lsp/lsproto/_generate/generate.mts | Implements jsonName support in generated tags/unmarshal logic and defines VS auto-insert/custom structure/request metadata. |
| internal/ls/jsxclosingtag.go | Enriches closing-tag completion results with VS snippet TextEdit + format. |
| internal/fourslash/fourslash.go | Updates closing-tag baseline range selection to prefer VS text-edit range when present. |
|
There's a lot of overlap between this code and what's in |
…to-insertion Implement the VS-specific _vs_onAutoInsert LSP method so that closing HTML/JSX tags are automatically inserted when typing '>' in Visual Studio. - Add VsOnAutoInsertOptions, VsOnAutoInsertParams, and VsOnAutoInsertResponseItem protocol types with correct _vs_ prefixed JSON field names matching VS LSP client expectations - Register _vs_onAutoInsertProvider server capability with _vs_triggerCharacters - Add handler that delegates to existing ProvideClosingTagCompletion - Fix jsonName bug in code generator unmarshal switch case Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
30c5c6e to
fb11b7e
Compare
…ptional - Only populate _vs_textEdit/_vs_textEditFormat when client is VS - Mark VS fields as optional in generate.mts (omitted from JSON for non-VS clients) - Extract buildClosingTagResponse helper to eliminate duplicated response construction - Guard VS handler on VsTextEdit != nil for safety Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The goFieldName() helper already converts _vs_ prefixed names to proper Go field names (e.g., _vs_textEdit -> VSTextEdit). Use property names that match the JSON wire format directly instead of adding a separate jsonName override. Also update hasTextDocumentURI/hasTextDocumentPosition to detect _vs_ variants for accessor method generation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Move the VS auto-insert business logic from handleVsOnAutoInsert in server.go into a new ProvideOnAutoInsert method in ls/jsxclosingtag.go. This keeps server.go as a thin wrapper and consolidates closing tag logic in one place, as ProvideOnAutoInsert delegates to the existing ProvideClosingTagCompletion internally. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Pushed in some changes which serve to deduplicate this; now, VS Code uses the VS style API, which removes the duplication entirely. The code gets simpler from this. I can see no difference in editor responsiveness; this is still way less chatty than completions. |
Implement the VS-specific _vs_onAutoInsert LSP method so that closing HTML/JSX tags are automatically inserted and properly mapped when typing '>' in Visual Studio.