Skip to content

Commit f2d49ea

Browse files
committed
add debug logging for microsoft#100828
1 parent 0a8fc57 commit f2d49ea

1 file changed

Lines changed: 30 additions & 15 deletions

File tree

extensions/vscode-api-tests/src/singlefolder-tests/window.test.ts

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as assert from 'assert';
7-
import { workspace, window, commands, ViewColumn, TextEditorViewColumnChangeEvent, Uri, Selection, Position, CancellationTokenSource, TextEditorSelectionChangeKind, QuickPickItem } from 'vscode';
7+
import { workspace, window, commands, ViewColumn, TextEditorViewColumnChangeEvent, Uri, Selection, Position, CancellationTokenSource, TextEditorSelectionChangeKind, QuickPickItem, TextEditor } from 'vscode';
88
import { join } from 'path';
99
import { closeAllEditors, pathEquals, createRandomFile } from '../utils';
1010

11+
1112
suite('vscode API - window', () => {
1213

1314
teardown(closeAllEditors);
@@ -145,22 +146,36 @@ suite('vscode API - window', () => {
145146
});
146147
});
147148

148-
// test('active editor not always correct... #49125', async function () {
149-
// const randomFile1 = await createRandomFile();
150-
// const randomFile2 = await createRandomFile();
149+
test('active editor not always correct... #49125', async function () {
151150

152-
// const [docA, docB] = await Promise.all([
153-
// workspace.openTextDocument(randomFile1),
154-
// workspace.openTextDocument(randomFile2)
155-
// ]);
156-
// for (let c = 0; c < 4; c++) {
157-
// let editorA = await window.showTextDocument(docA, ViewColumn.One);
158-
// assert.equal(window.activeTextEditor, editorA);
151+
function assertActiveEditor(editor: TextEditor) {
152+
if (window.activeTextEditor === editor) {
153+
assert.ok(true);
154+
return;
155+
}
156+
function printEditor(editor: TextEditor): string {
157+
return `doc: ${editor.document.uri.toString()}, column: ${editor.viewColumn}, active: ${editor === window.activeTextEditor}`;
158+
}
159+
const visible = window.visibleTextEditors.map(editor => printEditor(editor));
160+
assert.ok(false, `ACTIVE editor should be ${printEditor(editor)}, BUT HAVING ${visible.join(', ')}`);
159161

160-
// let editorB = await window.showTextDocument(docB, ViewColumn.Two);
161-
// assert.equal(window.activeTextEditor, editorB);
162-
// }
163-
// });
162+
}
163+
164+
const randomFile1 = await createRandomFile();
165+
const randomFile2 = await createRandomFile();
166+
167+
const [docA, docB] = await Promise.all([
168+
workspace.openTextDocument(randomFile1),
169+
workspace.openTextDocument(randomFile2)
170+
]);
171+
for (let c = 0; c < 4; c++) {
172+
let editorA = await window.showTextDocument(docA, ViewColumn.One);
173+
assertActiveEditor(editorA);
174+
175+
let editorB = await window.showTextDocument(docB, ViewColumn.Two);
176+
assertActiveEditor(editorB);
177+
}
178+
});
164179

165180
test('default column when opening a file', async () => {
166181
const [docA, docB, docC] = await Promise.all([

0 commit comments

Comments
 (0)