Skip to content

Commit d2232af

Browse files
committed
⚗️ Add test to verify SnippetSession.createEditsAndSnippetsFromEdits resolves $SELECTION variable
Signed-off-by: Babak K. Shandiz <[email protected]>
1 parent c6d246e commit d2232af

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/vs/editor/contrib/snippet/test/browser/snippetSession.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,5 +781,23 @@ suite('SnippetSession', function () {
781781
assert.strictEqual(result.snippets.length, 1);
782782
assert.strictEqual(result.snippets[0].isTrivialSnippet, false);
783783
});
784+
785+
test('with $SELECTION variable', function () {
786+
editor.getModel().setValue('Some text and a selection');
787+
editor.setSelections([new Selection(1, 17, 1, 26)]);
788+
789+
const result = SnippetSession.createEditsAndSnippetsFromEdits(
790+
editor,
791+
[{ range: new Range(1, 17, 1, 26), template: 'wrapped <$SELECTION>' }],
792+
true, true, undefined, undefined, languageConfigurationService
793+
);
794+
795+
assert.strictEqual(result.edits.length, 1);
796+
assert.deepStrictEqual(result.edits[0].range, new Range(1, 17, 1, 26));
797+
assert.deepStrictEqual(result.edits[0].text, 'wrapped <selection>');
798+
799+
assert.strictEqual(result.snippets.length, 1);
800+
assert.strictEqual(result.snippets[0].isTrivialSnippet, true);
801+
});
784802
});
785803
});

0 commit comments

Comments
 (0)