optionally allow to specify selection at which to insert a snippet, #19116

This commit is contained in:
Johannes Rieken
2017-01-25 15:56:02 +01:00
parent bedb191acc
commit a2a077b088
6 changed files with 38 additions and 9 deletions

View File

@@ -49,7 +49,7 @@ suite('editor tests', () => {
});
});
test('insert snippet with replacement', () => {
test('insert snippet with replacement, editor selection', () => {
const snippetString = new SnippetString()
.appendText('has been');
@@ -67,6 +67,24 @@ suite('editor tests', () => {
});
});
test('insert snippet with replacement, selection as argument', () => {
const snippetString = new SnippetString()
.appendText('has been');
return withRandomFileEditor('This will be replaced', (editor, doc) => {
const selection = new Selection(
new Position(0, 5),
new Position(0, 12)
);
return editor.insertSnippet(snippetString, selection).then(inserted => {
assert.ok(inserted);
assert.equal(doc.getText(), 'This has been replaced');
assert.ok(doc.isDirty);
});
});
});
test('make edit', () => {
return withRandomFileEditor('', (editor, doc) => {
return editor.edit((builder) => {