@@ -535,6 +535,17 @@ export class SnippetSession {
535
535
const parser = new SnippetParser ( ) ;
536
536
const snippet = new TextmateSnippet ( ) ;
537
537
538
+ // snippet variables resolver
539
+ const resolver = new CompositeSnippetVariableResolver ( [
540
+ editor . invokeWithinContext ( accessor => new ModelBasedVariableResolver ( accessor . get ( ILabelService ) , model ) ) ,
541
+ new ClipboardBasedVariableResolver ( ( ) => clipboardText , 0 , editor . getSelections ( ) . length , editor . getOption ( EditorOption . multiCursorPaste ) === 'spread' ) ,
542
+ new SelectionBasedVariableResolver ( model , editor . getSelection ( ) , 0 , overtypingCapturer ) ,
543
+ new CommentBasedVariableResolver ( model , editor . getSelection ( ) , languageConfigurationService ) ,
544
+ new TimeBasedVariableResolver ,
545
+ new WorkspaceBasedVariableResolver ( editor . invokeWithinContext ( accessor => accessor . get ( IWorkspaceContextService ) ) ) ,
546
+ new RandomBasedVariableResolver ,
547
+ ] ) ;
548
+
538
549
//
539
550
snippetEdits = snippetEdits . sort ( ( a , b ) => Range . compareRangesUsingStarts ( a . range , b . range ) ) ;
540
551
let offset = 0 ;
@@ -553,6 +564,7 @@ export class SnippetSession {
553
564
}
554
565
555
566
parser . parseFragment ( template , snippet ) ;
567
+ snippet . resolveVariables ( resolver ) ;
556
568
557
569
const snippetText = snippet . toString ( ) ;
558
570
const snippetFragmentText = snippetText . slice ( offset ) ;
@@ -568,19 +580,6 @@ export class SnippetSession {
568
580
//
569
581
parser . ensureFinalTabstop ( snippet , enforceFinalTabstop , true ) ;
570
582
571
- // snippet variables resolver
572
- const resolver = new CompositeSnippetVariableResolver ( [
573
- editor . invokeWithinContext ( accessor => new ModelBasedVariableResolver ( accessor . get ( ILabelService ) , model ) ) ,
574
- new ClipboardBasedVariableResolver ( ( ) => clipboardText , 0 , editor . getSelections ( ) . length , editor . getOption ( EditorOption . multiCursorPaste ) === 'spread' ) ,
575
- new SelectionBasedVariableResolver ( model , editor . getSelection ( ) , 0 , overtypingCapturer ) ,
576
- new CommentBasedVariableResolver ( model , editor . getSelection ( ) , languageConfigurationService ) ,
577
- new TimeBasedVariableResolver ,
578
- new WorkspaceBasedVariableResolver ( editor . invokeWithinContext ( accessor => accessor . get ( IWorkspaceContextService ) ) ) ,
579
- new RandomBasedVariableResolver ,
580
- ] ) ;
581
- snippet . resolveVariables ( resolver ) ;
582
-
583
-
584
583
return {
585
584
edits,
586
585
snippets : [ new OneSnippet ( editor , snippet , '' ) ]
0 commit comments