mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 03:29:00 +01:00
Introduce 'keepWhitespace' property for snippet text edit abstractions.
- Restore original behaviour of bulk text edits adjusting whitespace - Add testcase Signed-off-by: Roland Grunberg <rgrunber@redhat.com>
This commit is contained in:
@@ -1226,6 +1226,27 @@ suite('vscode API - workspace', () => {
|
||||
assert.deepStrictEqual(edt.selections, [new vscode.Selection(0, 0, 0, 3)]);
|
||||
});
|
||||
|
||||
test('SnippetString in WorkspaceEdit with keepWhitespace', async function (): Promise<any> {
|
||||
const file = await createRandomFile('This is line 1\n ');
|
||||
|
||||
const document = await vscode.workspace.openTextDocument(file);
|
||||
const edt = await vscode.window.showTextDocument(document);
|
||||
|
||||
assert.ok(edt === vscode.window.activeTextEditor);
|
||||
|
||||
const snippetText = new vscode.SnippetTextEdit(new vscode.Range(1, 3, 1, 3), new vscode.SnippetString('This is line 2\n This is line 3'));
|
||||
snippetText.keepWhitespace = true;
|
||||
const we = new vscode.WorkspaceEdit();
|
||||
we.set(document.uri, [snippetText]);
|
||||
const success = await vscode.workspace.applyEdit(we);
|
||||
if (edt !== vscode.window.activeTextEditor) {
|
||||
return this.skip();
|
||||
}
|
||||
|
||||
assert.ok(success);
|
||||
assert.strictEqual(document.getText(), 'This is line 1\n This is line 2\n This is line 3');
|
||||
});
|
||||
|
||||
test('Support creating binary files in a WorkspaceEdit', async function (): Promise<any> {
|
||||
|
||||
const fileUri = vscode.Uri.parse(`${testFs.scheme}:/${rndName()}`);
|
||||
|
||||
Reference in New Issue
Block a user