mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 02:58:56 +01:00
do a sync check for the editor before waiting for an event, fixes #12280
This commit is contained in:
@@ -190,7 +190,22 @@ export class MainThreadEditors extends MainThreadEditorsShape {
|
||||
return;
|
||||
}
|
||||
|
||||
return new TPromise<void>(c => {
|
||||
const findEditor = (): string => {
|
||||
// find the editor we have just opened and return the
|
||||
// id we have assigned to it.
|
||||
for (let id in this._textEditorsMap) {
|
||||
if (this._textEditorsMap[id].matches(editor)) {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const syncEditorId = findEditor();
|
||||
if (syncEditorId) {
|
||||
return TPromise.as(syncEditorId);
|
||||
}
|
||||
|
||||
return new TPromise<void>(resolve => {
|
||||
// not very nice but the way it is: changes to the editor state aren't
|
||||
// send to the ext host as they happen but stuff is delayed a little. in
|
||||
// order to provide the real editor on #openTextEditor we need to sync on
|
||||
@@ -200,7 +215,7 @@ export class MainThreadEditors extends MainThreadEditorsShape {
|
||||
function contd() {
|
||||
subscription.dispose();
|
||||
clearTimeout(handle);
|
||||
c(undefined);
|
||||
resolve(undefined);
|
||||
}
|
||||
subscription = this._editorTracker.onDidUpdateTextEditors(() => {
|
||||
contd();
|
||||
@@ -209,15 +224,7 @@ export class MainThreadEditors extends MainThreadEditorsShape {
|
||||
contd();
|
||||
}, 1000);
|
||||
|
||||
}).then(() => {
|
||||
// find the editor we have just opened and return the
|
||||
// id we have assigned to it.
|
||||
for (let id in this._textEditorsMap) {
|
||||
if (this._textEditorsMap[id].matches(editor)) {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
});
|
||||
}).then(findEditor);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user