diff options
Diffstat (limited to 'src/vs/editor/contrib/snippet/browser/snippetSession.ts')
-rw-r--r-- | src/vs/editor/contrib/snippet/browser/snippetSession.ts | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/vs/editor/contrib/snippet/browser/snippetSession.ts b/src/vs/editor/contrib/snippet/browser/snippetSession.ts index 74eaa5847f7..a25ee16b15c 100644 --- a/src/vs/editor/contrib/snippet/browser/snippetSession.ts +++ b/src/vs/editor/contrib/snippet/browser/snippetSession.ts @@ -535,6 +535,17 @@ export class SnippetSession { const parser = new SnippetParser(); const snippet = new TextmateSnippet(); + // snippet variables resolver + const resolver = new CompositeSnippetVariableResolver([ + editor.invokeWithinContext(accessor => new ModelBasedVariableResolver(accessor.get(ILabelService), model)), + new ClipboardBasedVariableResolver(() => clipboardText, 0, editor.getSelections().length, editor.getOption(EditorOption.multiCursorPaste) === 'spread'), + new SelectionBasedVariableResolver(model, editor.getSelection(), 0, overtypingCapturer), + new CommentBasedVariableResolver(model, editor.getSelection(), languageConfigurationService), + new TimeBasedVariableResolver, + new WorkspaceBasedVariableResolver(editor.invokeWithinContext(accessor => accessor.get(IWorkspaceContextService))), + new RandomBasedVariableResolver, + ]); + // snippetEdits = snippetEdits.sort((a, b) => Range.compareRangesUsingStarts(a.range, b.range)); let offset = 0; @@ -553,6 +564,7 @@ export class SnippetSession { } parser.parseFragment(template, snippet); + snippet.resolveVariables(resolver); const snippetText = snippet.toString(); const snippetFragmentText = snippetText.slice(offset); @@ -568,19 +580,6 @@ export class SnippetSession { // parser.ensureFinalTabstop(snippet, enforceFinalTabstop, true); - // snippet variables resolver - const resolver = new CompositeSnippetVariableResolver([ - editor.invokeWithinContext(accessor => new ModelBasedVariableResolver(accessor.get(ILabelService), model)), - new ClipboardBasedVariableResolver(() => clipboardText, 0, editor.getSelections().length, editor.getOption(EditorOption.multiCursorPaste) === 'spread'), - new SelectionBasedVariableResolver(model, editor.getSelection(), 0, overtypingCapturer), - new CommentBasedVariableResolver(model, editor.getSelection(), languageConfigurationService), - new TimeBasedVariableResolver, - new WorkspaceBasedVariableResolver(editor.invokeWithinContext(accessor => accessor.get(IWorkspaceContextService))), - new RandomBasedVariableResolver, - ]); - snippet.resolveVariables(resolver); - - return { edits, snippets: [new OneSnippet(editor, snippet, '')] |