File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -346,7 +346,11 @@ export async function activate(context: ExtensionContext): Promise<ExtensionAPI>
346346 for ( const edit of docChange . edits ) {
347347 if ( "snippet" in edit ) {
348348 documentUris . push ( Uri . parse ( docChange . textDocument . uri ) . toString ( ) ) ;
349- const snippet = new SnippetTextEdit ( client . protocol2CodeConverter . asRange ( ( edit as any ) . range ) , new SnippetString ( ( edit as any ) . snippet . value ) ) ;
349+ const snippetValue = ( edit as any ) . snippet . value ;
350+ const snippet = new SnippetTextEdit (
351+ client . protocol2CodeConverter . asRange ( ( edit as any ) . range ) ,
352+ new SnippetString ( escapeSnippetLiterals ( snippetValue ) )
353+ ) ;
350354 if ( semver . gte ( version , '1.98.0' ) ) {
351355 snippet [ "keepWhitespace" ] = true ;
352356 }
@@ -1267,3 +1271,9 @@ function registerRestartJavaLanguageServerCommand(context: ExtensionContext) {
12671271 }
12681272 } ) ) ;
12691273}
1274+
1275+ function escapeSnippetLiterals ( value : string ) : string {
1276+ return value
1277+ . replace ( / \\ / g, '\\\\' ) // Escape backslashes
1278+ . replace ( / \$ (? ! \{ ) / g, '\\$' ) ; // Escape $ only if NOT followed by {
1279+ }
You can’t perform that action at this time.
0 commit comments