Description
The goal
VSCode has support for snippets that can take a selection. We'd like to use this to enable things such as "if state wrap air", "try state wrap air", etc
Implementation plan
Extension
We propose to add a new action. Check out simple actions like ExtractVariable
as a starting point.
The action will call editor.insertSnippet
.
We will keep language-specific snippets for each syntactic scope type, similar to how we do for finding containing scope; see eg https://github.com/pokey/cursorless-vscode/blob/fdebfe93c7871a3e3bf832532f51cf64b8f3c3a8/src/languages/python.ts#L46-L68 Note that the snippet will leverage TM_SELECTED_TEXT
to refer to where the target that is wrapped will go. We can add tabstops for things like if statement guard, catch block, etc
The action will take an extra arg which is the scopetype to wrap with, eg ifStatement
. See Wrap
for example of taking extra args
Talon
Add a new capture like "wrap" that accepts a scope type. Something like "<scopeType> wrap <target>"