if needed , read clipboard inside MainThreadEditors#insertText, https://github.com/microsoft/vscode/issues/98497

This commit is contained in:
Johannes Rieken
2020-06-08 12:03:01 +02:00
parent dca516e9d1
commit 48a2d3e863
6 changed files with 55 additions and 6 deletions

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { workspace, window, Position, Range, commands, TextEditor, TextDocument, TextEditorCursorStyle, TextEditorLineNumbersStyle, SnippetString, Selection, Uri } from 'vscode';
import { workspace, window, Position, Range, commands, TextEditor, TextDocument, TextEditorCursorStyle, TextEditorLineNumbersStyle, SnippetString, Selection, Uri, env } from 'vscode';
import { createRandomFile, deleteFile, closeAllEditors } from '../utils';
suite('vscode API - editors', () => {
@@ -47,6 +47,20 @@ suite('vscode API - editors', () => {
});
});
test('insert snippet with clipboard variables', async () => {
await env.clipboard.writeText('INTEGRATION-TESTS');
const snippetString = new SnippetString('running: $CLIPBOARD');
return withRandomFileEditor('', async (editor, doc) => {
const inserted = await editor.insertSnippet(snippetString);
assert.ok(inserted);
assert.equal(doc.getText(), 'running: INTEGRATION-TESTS');
assert.ok(doc.isDirty);
});
});
test('insert snippet with replacement, editor selection', () => {
const snippetString = new SnippetString()
.appendText('has been');