mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 19:18:59 +01:00
Merge branch 'joh/editors'
This commit is contained in:
@@ -6,7 +6,8 @@
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { workspace, window, Position, Range, commands, TextEditor, TextDocument, TextEditorCursorStyle, TextEditorLineNumbersStyle, SnippetString, Selection } from 'vscode';
|
||||
import { join } from 'path';
|
||||
import { workspace, window, Position, Range, commands, TextEditor, TextDocument, TextEditorCursorStyle, TextEditorLineNumbersStyle, SnippetString, Selection, ViewColumn } from 'vscode';
|
||||
import { createRandomFile, deleteFile, cleanUp } from './utils';
|
||||
|
||||
suite('editor tests', () => {
|
||||
@@ -109,6 +110,66 @@ suite('editor tests', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('issue #20867: vscode.window.visibleTextEditors returns closed document 1/2', () => {
|
||||
|
||||
return withRandomFileEditor('Hello world!', editor => {
|
||||
|
||||
const p = new Promise((resolve, reject) => {
|
||||
const sub = workspace.onDidCloseTextDocument(doc => {
|
||||
try {
|
||||
sub.dispose();
|
||||
assert.ok(window.activeTextEditor === undefined);
|
||||
assert.equal(window.visibleTextEditors.length, 0);
|
||||
resolve();
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return Promise.all([
|
||||
commands.executeCommand('workbench.action.closeAllEditors'),
|
||||
p
|
||||
]).then(() => undefined);
|
||||
});
|
||||
});
|
||||
|
||||
test('issue #20867: vscode.window.visibleTextEditors returns closed document 2/2', () => {
|
||||
|
||||
const file10Path = join(workspace.rootPath || '', './10linefile.ts');
|
||||
const file30Path = join(workspace.rootPath || '', './30linefile.ts');
|
||||
|
||||
return Promise.all([
|
||||
workspace.openTextDocument(file10Path),
|
||||
workspace.openTextDocument(file30Path)
|
||||
]).then(docs => {
|
||||
return Promise.all([
|
||||
window.showTextDocument(docs[0], ViewColumn.One),
|
||||
window.showTextDocument(docs[1], ViewColumn.Two),
|
||||
]);
|
||||
}).then(editors => {
|
||||
|
||||
const p = new Promise((resolve, reject) => {
|
||||
const sub = workspace.onDidCloseTextDocument(doc => {
|
||||
try {
|
||||
sub.dispose();
|
||||
assert.ok(window.activeTextEditor === editors[1]);
|
||||
assert.ok(window.visibleTextEditors[0] === editors[1]);
|
||||
assert.equal(window.visibleTextEditors.length, 1);
|
||||
resolve();
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// hide doesn't what it means because it triggers a close event and because it
|
||||
// detached the editor. For this test that's what we want.
|
||||
editors[0].hide();
|
||||
return p;
|
||||
});
|
||||
});
|
||||
|
||||
function executeReplace(editor: TextEditor, range: Range, text: string, undoStopBefore: boolean, undoStopAfter: boolean): Thenable<boolean> {
|
||||
return editor.edit((builder) => {
|
||||
builder.replace(range, text);
|
||||
|
||||
Reference in New Issue
Block a user