提交 37975119 编写于 作者: J Johannes Rieken

fix #58888 and fix a little mem leak

上级 4e3f58f2
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
import { IModelService, shouldSynchronizeModel } from 'vs/editor/common/services/modelService'; import { IModelService, shouldSynchronizeModel } from 'vs/editor/common/services/modelService';
import { ITextModel } from 'vs/editor/common/model'; import { ITextModel } from 'vs/editor/common/model';
import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { IDisposable, dispose, combinedDisposable } from 'vs/base/common/lifecycle';
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
import { Event, Emitter } from 'vs/base/common/event'; import { Event, Emitter } from 'vs/base/common/event';
import { ExtHostContext, ExtHostDocumentsAndEditorsShape, IModelAddedData, ITextEditorAddData, IDocumentsAndEditorsDelta, IExtHostContext, MainContext } from '../node/extHost.protocol'; import { ExtHostContext, ExtHostDocumentsAndEditorsShape, IModelAddedData, ITextEditorAddData, IDocumentsAndEditorsDelta, IExtHostContext, MainContext } from '../node/extHost.protocol';
...@@ -173,7 +173,7 @@ class MainThreadDocumentAndEditorStateComputer { ...@@ -173,7 +173,7 @@ class MainThreadDocumentAndEditorStateComputer {
@IPanelService private readonly _panelService: IPanelService @IPanelService private readonly _panelService: IPanelService
) { ) {
this._modelService.onModelAdded(this._updateStateOnModelAdd, this, this._toDispose); this._modelService.onModelAdded(this._updateStateOnModelAdd, this, this._toDispose);
this._modelService.onModelRemoved(this._updateState, this, this._toDispose); this._modelService.onModelRemoved(_ => this._updateState(), this, this._toDispose);
this._codeEditorService.onCodeEditorAdd(this._onDidAddEditor, this, this._toDispose); this._codeEditorService.onCodeEditorAdd(this._onDidAddEditor, this, this._toDispose);
this._codeEditorService.onCodeEditorRemove(this._onDidRemoveEditor, this, this._toDispose); this._codeEditorService.onCodeEditorRemove(this._onDidRemoveEditor, this, this._toDispose);
...@@ -191,8 +191,11 @@ class MainThreadDocumentAndEditorStateComputer { ...@@ -191,8 +191,11 @@ class MainThreadDocumentAndEditorStateComputer {
} }
private _onDidAddEditor(e: ICodeEditor): void { private _onDidAddEditor(e: ICodeEditor): void {
this._toDisposeOnEditorRemove.set(e.getId(), e.onDidChangeModel(() => this._updateState())); this._toDisposeOnEditorRemove.set(e.getId(), combinedDisposable([
this._toDisposeOnEditorRemove.set(e.getId(), e.onDidFocusEditorText(() => this._updateState())); e.onDidChangeModel(() => this._updateState()),
e.onDidFocusEditorText(() => this._updateState()),
e.onDidFocusEditorWidget(() => this._updateState(e))
]));
this._updateState(); this._updateState();
} }
...@@ -231,7 +234,7 @@ class MainThreadDocumentAndEditorStateComputer { ...@@ -231,7 +234,7 @@ class MainThreadDocumentAndEditorStateComputer {
)); ));
} }
private _updateState(): void { private _updateState(widgetFocusCandidate?: ICodeEditor): void {
// models: ignore too large models // models: ignore too large models
const models = new Set<ITextModel>(); const models = new Set<ITextModel>();
...@@ -256,7 +259,11 @@ class MainThreadDocumentAndEditorStateComputer { ...@@ -256,7 +259,11 @@ class MainThreadDocumentAndEditorStateComputer {
) { ) {
const apiEditor = new TextEditorSnapshot(editor); const apiEditor = new TextEditorSnapshot(editor);
editors.set(apiEditor.id, apiEditor); editors.set(apiEditor.id, apiEditor);
if (editor.hasTextFocus()) { if (editor.hasTextFocus() || (widgetFocusCandidate === editor && editor.hasWidgetFocus())) {
// text focus has priority, widget focus is tricky because multiple
// editors might claim widget focus at the same time. therefore we use a
// candidate (which is the editor that has raised an widget focus event)
// in addition to the widget focus check
activeEditor = apiEditor.id; activeEditor = apiEditor.id;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册