Repository navigation
Closed
Description
From time to time the integration tests fail and that's because the active editor isn't the editor that just got opened. That actually a problem not a flawed test... Below a trace I could extract with the following extension snippet
- apply this patch to add logging patch.txt
- have the extension snippet below, bind the command to a keybindg
- execute the command and notice that it breaks after one iteration
vscode.window.onDidChangeActiveTextEditor(e => {
console.log('ACTIVE editor -> ' + (e ? e.document.fileName : '<none>'));
})
vscode.commands.registerCommand('extension.sayHello', async () => {
console.log('START')
const [docA, docB] = await Promise.all([
vscode.workspace.openTextDocument('/Users/jrieken/Code/_samples/virtual/out/extension.js'),
vscode.workspace.openTextDocument('/Users/jrieken/Code/_samples/virtual/out/extension.js.map')
]);
let c = 3;
while (c > 0) {
console.log('NEW ROUND');
console.log('want', docA.fileName, c);
let editorA = await vscode.window.showTextDocument(docA, vscode.ViewColumn.One);
if (vscode.window.activeTextEditor !== editorA) {
console.log('editorA BAD', editorA.document.fileName, c);
break;
}
console.log('want', docB.fileName, c);
let editorB = await vscode.window.showTextDocument(docB, vscode.ViewColumn.Two);
if (vscode.window.activeTextEditor !== editorB) {
console.log('editorB BAD', editorB.document.fileName, c);
break;
}
c -= 1;
}
});[Extension Host] NEW ROUND (at /Users/jrieken/Code/_samples/virtual/out/extension.js:49:21)
console.js:100 [Extension Host] want /Users/jrieken/Code/_samples/virtual/out/extension.js 2 (at /Users/jrieken/Code/_samples/virtual/out/extension.js:50:21)
console.js:100 [Extension Host] editorA BAD /Users/jrieken/Code/_samples/virtual/out/extension.js 2 (at /Users/jrieken/Code/_samples/virtual/out/extension.js:53:25)
mainThreadDocumentsAndEditors.js:168 at MainThreadDocumentAndEditorStateComputer._updateState (file:///Users/jrieken/Code/vscode/out/vs/workbench/api/electron-browser/mainThreadDocumentsAndEditors.js:168:25)
at file:///Users/jrieken/Code/vscode/out/vs/workbench/api/electron-browser/mainThreadDocumentsAndEditors.js:142:113
at Emitter.fire (file:///Users/jrieken/Code/vscode/out/vs/base/common/event.js:103:38)
console.js:100 [Extension Host] ACTIVE editor -> /Users/jrieken/Code/_samples/virtual/out/extension.js (at vscode.window.onDidChangeActiveTextEditor.e (/Users/jrieken/Code/_samples/virtual/out/extension.js:39:17))
Activity
jrieken commentedon May 4, 2018
Removing tests should be reverted once this is fixed: efb4358
jrieken commentedon May 4, 2018
Benjamin Pasero (@bpasero) alexandrudima Not sure how this should work. I see that focus isn't called from the workbench when opening a document that is already open. Still, while the editor takes focus there is no event emitted.
use Text blur/focus events, #49125
bpasero commentedon May 7, 2018
There is something fishy going on, I also sometimes see 2 blinking cursors in the editor area when running the sample. I extracted #49330 to look into this and see if the workbench is doing something weird.
aeschli commentedon Jun 1, 2018
verified by running the code above without seeing any BAD