Fixed
:snippetvisual selection not captured — running:snippet <name>from visual mode now correctly wraps the selected text. Previously,$TM_SELECTED_TEXT/$VISUALresolved to empty and the snippet was inserted at the cursor instead of replacing the selection. Root cause: vim's ex-command dispatcher callsexitVisualMode()before the:snippethandler runs, collapsing the CM6 selection. Fixed by reading the visual selection from vim's'<'/'>'marks (which surviveexitVisualMode) via thecmadapter parameter, extracting the text withcm.getRange(), and overridingctx.selectedTextbefore preprocessing. Visual line mode (V) normalizes the start toch: 0and extends the end to full line length. (Discussion #108)- Plugin:
src/snippets/commands.ts(recoverVisualSelection()— reads'<'/'>'marks +lastSelection.visualMode/visualLineflags;:snippethandler overridesctx.selectedTextand uses mark-derivedfrom/tooffsets for theapply()range)
- Plugin:
Tests
- 10 e2e tests in
test/specs/spikes/spike-snippet-visual-surround.e2e.ts(Discussion #108):$TM_SELECTED_TEXTwraps word selection viaviw, fills tabstop default in link snippet,$VISUALalias parity, multiline callout wrapping, empty selection regression guard, link snippet structure, Luafmt()wraps selection, Luat()/i()bold wrapping, Lua link structure, Lua empty selection placeholder - 12 e2e tests in
test/specs/spikes/spike-snippet-visual-edge-cases.e2e.ts(Discussion #108): visual line mode (V) wraps full line, multi-lineVjjwraps three lines, charwisevacross lines, visual block mode (<C-v>) produces non-empty text, stalelastSelectionuses marks (vimgvsemantics), bookmark invalidation falls back to empty, picker baseline, normal mode after visual:snippet(documented pre-existing), correct snippet text despite normal mode,v$end-of-line, single char at EOL,v$mid-line to end
Documentation
CHANGELOG.mdKNOWN_LIMITATIONS.md: Updated snippet variable limitations section —$TM_SELECTED_TEXT/$VISUALtab-expand limitation clarified, visual-mode:snippetnow worksCONTRIBUTING.md: Addedcommands.tsto snippets codebase structure with visual selection recovery descriptiondocs/features/snippets.md: Updated$TM_SELECTED_TEXT/$VISUALcallout to confirm visual-mode:snippetworks
Full Changelog: 0.99.0...0.100.0