Add API to open a file or diff editor on a specific selection range (fixes #30241)

This commit is contained in:
Benjamin Pasero
2017-07-07 12:20:34 +02:00
parent 6af048189e
commit f381ce961d
7 changed files with 37 additions and 10 deletions

View File

@@ -260,6 +260,19 @@ suite('workspace-namespace', () => {
});
});
test('openTextDocument, with selection', function () {
return createRandomFile('foo\nbar\nbar').then(file => {
return vscode.workspace.openTextDocument(file).then(doc => {
return vscode.window.showTextDocument(doc, { selection: new vscode.Range(new vscode.Position(1, 1), new vscode.Position(1, 2)) }).then(editor => {
assert.equal(editor.selection.start.line, 1);
assert.equal(editor.selection.start.character, 1);
assert.equal(editor.selection.end.line, 1);
assert.equal(editor.selection.end.character, 2);
});
});
});
});
test('registerTextDocumentContentProvider, simple', function () {
let registration = vscode.workspace.registerTextDocumentContentProvider('foo', {