mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 02:58:56 +01:00
fix #24457
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { join } from 'path';
|
||||
import { workspace, window, Position, Range, commands, TextEditor, TextDocument, TextEditorCursorStyle, TextEditorLineNumbersStyle, SnippetString, Selection, ViewColumn } from 'vscode';
|
||||
import { workspace, window, Position, Range, commands, TextEditor, TextDocument, TextEditorCursorStyle, TextEditorLineNumbersStyle, SnippetString, Selection, ViewColumn, Uri } from 'vscode';
|
||||
import { createRandomFile, deleteFile, cleanUp } from './utils';
|
||||
|
||||
suite('editor tests', () => {
|
||||
@@ -112,8 +112,7 @@ suite('editor tests', () => {
|
||||
|
||||
test('issue #20867: vscode.window.visibleTextEditors returns closed document 1/2', () => {
|
||||
|
||||
return withRandomFileEditor('Hello world!', editor => {
|
||||
|
||||
return commands.executeCommand('vscode.open', Uri.file(join(workspace.rootPath || '', './10linefile.ts'))).then(() => {
|
||||
const p = new Promise((resolve, reject) => {
|
||||
const sub = workspace.onDidCloseTextDocument(doc => {
|
||||
try {
|
||||
@@ -128,40 +127,30 @@ suite('editor tests', () => {
|
||||
});
|
||||
|
||||
return Promise.all([
|
||||
delay(800).then(() => commands.executeCommand('workbench.action.closeAllEditors')), // TODO@Ben TODO@Joh this delay is a hack
|
||||
commands.executeCommand('workbench.action.closeAllEditors'),
|
||||
p
|
||||
]).then(() => undefined);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
function delay(time) {
|
||||
return new Promise(function (fulfill) {
|
||||
setTimeout(fulfill, time);
|
||||
});
|
||||
}
|
||||
|
||||
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 => {
|
||||
commands.executeCommand('vscode.open', Uri.file(file10Path), ViewColumn.One),
|
||||
commands.executeCommand('vscode.open', Uri.file(file30Path), ViewColumn.Two)
|
||||
]).then(() => {
|
||||
|
||||
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);
|
||||
assert.ok(window.activeTextEditor);
|
||||
assert.equal(window.activeTextEditor!.document.uri.fsPath, file30Path);
|
||||
resolve();
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
@@ -171,11 +160,9 @@ suite('editor tests', () => {
|
||||
|
||||
// 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.
|
||||
delay(800).then(() => { // TODO@Ben TODO@Joh this delay is a hack
|
||||
editors[0].hide();
|
||||
|
||||
return p;
|
||||
});
|
||||
assert.equal(window.visibleTextEditors.length, 2);
|
||||
window.visibleTextEditors[0].hide();
|
||||
return p;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user