|
4 | 4 | *--------------------------------------------------------------------------------------------*/ |
5 | 5 |
|
6 | 6 | 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'; |
8 | 8 | import { join } from 'path'; |
9 | 9 | import { closeAllEditors, pathEquals, createRandomFile } from '../utils'; |
10 | 10 |
|
| 11 | + |
11 | 12 | suite('vscode API - window', () => { |
12 | 13 |
|
13 | 14 | teardown(closeAllEditors); |
@@ -145,22 +146,36 @@ suite('vscode API - window', () => { |
145 | 146 | }); |
146 | 147 | }); |
147 | 148 |
|
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 () { |
151 | 150 |
|
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(', ')}`); |
159 | 161 |
|
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 | + }); |
164 | 179 |
|
165 | 180 | test('default column when opening a file', async () => { |
166 | 181 | const [docA, docB, docC] = await Promise.all([ |
|
0 commit comments