You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From now on, the editor widget open promise resolution does not rely on
internal Theia events but solely on @phosphor's `isAttached`/`isVisible`
properties.
The editor widget promise resolves with the next task after a navigation
frame so the browser can render the widget.
Closes#1612
Signed-off-by: Akos Kitta <[email protected]>
@@ -135,39 +130,36 @@ export class OpenSketchFiles extends SketchContribution {
135
130
constwidget=this.editorManager.all.find(
136
131
(widget)=>widget.editor.uri.toString()===uri
137
132
);
133
+
if(widget&&!forceOpen){
134
+
returnwidget;
135
+
}
136
+
138
137
constdisposables=newDisposableCollection();
139
-
if(!widget||forceOpen){
140
-
constdeferred=newDeferred<EditorWidget>();
138
+
constdeferred=newDeferred<EditorWidget>();
139
+
// An editor can be in two primary states:
140
+
// - The editor is not yet opened. The `widget` is `undefined`. With `editorManager#open`, Theia will create an editor and fire an `editorManager#onCreated` event.
141
+
// - The editor is opened. Can be active, current, or open.
142
+
// - If the editor has the focus (the cursor blinks in the editor): it's the active editor.
143
+
// - If the editor does not have the focus (the focus is on a different widget or the context menu is opened in the editor): it's the current editor.
144
+
// - If the editor is not the top editor in the main area, it's opened.
145
+
if(!widget){
146
+
// If the widget is `undefined`, IDE2 expects one `onCreate` event. Subscribe to the `onCreated` event
147
+
// and resolve the promise with the editor only when the new editor's visibility changes.
141
148
disposables.push(
142
149
this.editorManager.onCreated((editor)=>{
143
150
if(editor.editor.uri.toString()===uri){
144
-
if(editor.isVisible){
145
-
disposables.dispose();
151
+
if(editor.isAttached&&editor.isVisible){
146
152
deferred.resolve(editor);
147
153
}else{
148
-
// In Theia, the promise resolves after opening the editor, but the editor is neither attached to the DOM, nor visible.
149
-
// This is a hack to first get an event from monaco after the widget update request, then IDE2 waits for the next monaco context key event.
150
-
// Here, the monaco context key event is not used, but this is the first event after the editor is visible in the UI.
0 commit comments