mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-20 16:49:06 +01:00
joh/theoretical quokka (#154157)
* add `SnippetController#apply(ISnippetEdit[])` This replaces the initial ugly trick with a more sound implementation of arbitrary snippet edits. A snippet edit can cover disconnected regions, each will be applied as separate text edit but everything will become a single `OneSnippet` instance * add integration test for SnippetString-text edit inside workspace edit
This commit is contained in:
@@ -1147,4 +1147,27 @@ suite('vscode API - workspace', () => {
|
||||
assert.strictEqual(document.isDirty, false);
|
||||
}
|
||||
});
|
||||
|
||||
test('SnippetString in WorkspaceEdit', async function (): Promise<any> {
|
||||
const file = await createRandomFile('hello\nworld');
|
||||
|
||||
const document = await vscode.workspace.openTextDocument(file);
|
||||
const edt = await vscode.window.showTextDocument(document);
|
||||
|
||||
assert.ok(edt === vscode.window.activeTextEditor);
|
||||
|
||||
const we = new vscode.WorkspaceEdit();
|
||||
we.set(document.uri, [{ range: new vscode.Range(0, 0, 0, 0), newText: '', newText2: new vscode.SnippetString('${1:foo}${2:bar}') }]);
|
||||
const success = await vscode.workspace.applyEdit(we);
|
||||
|
||||
|
||||
if (edt !== vscode.window.activeTextEditor) {
|
||||
return this.skip();
|
||||
}
|
||||
|
||||
assert.ok(success);
|
||||
assert.strictEqual(document.getText(), 'foobarhello\nworld');
|
||||
assert.deepStrictEqual(edt.selections, [new vscode.Selection(0, 0, 0, 3)]);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user