mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-11 05:30:03 -05:00
editors - call setEditorVisible before removing editor from DOM and thus remove onWillHide() method (fix #100271)
This commit is contained in:
@@ -33,9 +33,6 @@ export abstract class Composite extends Component implements IComposite {
|
||||
private readonly _onTitleAreaUpdate = this._register(new Emitter<void>());
|
||||
readonly onTitleAreaUpdate = this._onTitleAreaUpdate.event;
|
||||
|
||||
private readonly _onDidChangeVisibility = this._register(new Emitter<boolean>());
|
||||
readonly onDidChangeVisibility = this._onDidChangeVisibility.event;
|
||||
|
||||
private _onDidFocus: Emitter<void> | undefined;
|
||||
get onDidFocus(): Event<void> {
|
||||
if (!this._onDidFocus) {
|
||||
@@ -135,8 +132,6 @@ export abstract class Composite extends Component implements IComposite {
|
||||
setVisible(visible: boolean): void {
|
||||
if (this.visible !== !!visible) {
|
||||
this.visible = visible;
|
||||
|
||||
this._onDidChangeVisibility.fire(visible);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -137,11 +137,6 @@ export abstract class BaseEditor extends Composite implements IEditorPane {
|
||||
this._group = group;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called before the editor is being removed from the DOM.
|
||||
*/
|
||||
onWillHide() { }
|
||||
|
||||
protected getEditorMemento<T>(editorGroupService: IEditorGroupsService, key: string, limit: number = 10): IEditorMemento<T> {
|
||||
const mementoKey = `${this.getId()}${key}`;
|
||||
|
||||
|
||||
@@ -198,18 +198,19 @@ export class EditorControl extends Disposable {
|
||||
// Stop any running operation
|
||||
this.editorOperation.stop();
|
||||
|
||||
// Remove editor pane from parent and hide
|
||||
// Indicate to editor pane before removing the editor from
|
||||
// the DOM to give a chance to persist certain state that
|
||||
// might depend on still being the active DOM element.
|
||||
this._activeEditorPane.clearInput();
|
||||
this._activeEditorPane.setVisible(false, this.groupView);
|
||||
|
||||
// Remove editor pane from parent
|
||||
const editorPaneContainer = this._activeEditorPane.getContainer();
|
||||
if (editorPaneContainer) {
|
||||
this._activeEditorPane.onWillHide();
|
||||
this.parent.removeChild(editorPaneContainer);
|
||||
hide(editorPaneContainer);
|
||||
}
|
||||
|
||||
// Indicate to editor pane
|
||||
this._activeEditorPane.clearInput();
|
||||
this._activeEditorPane.setVisible(false, this.groupView);
|
||||
|
||||
// Clear active editor pane
|
||||
this.doSetActiveEditorPane(null);
|
||||
}
|
||||
|
||||
@@ -97,18 +97,17 @@ export class NotebookEditor extends BaseEditor {
|
||||
return this._widget.value;
|
||||
}
|
||||
|
||||
onWillHide() {
|
||||
this._saveEditorViewState(this.input);
|
||||
if (this.input && this._widget.value) {
|
||||
// the widget is not transfered to other editor inputs
|
||||
this._widget.value.onWillHide();
|
||||
}
|
||||
super.onWillHide();
|
||||
}
|
||||
|
||||
setEditorVisible(visible: boolean, group: IEditorGroup | undefined): void {
|
||||
super.setEditorVisible(visible, group);
|
||||
this._groupListener.value = group?.onWillCloseEditor(e => this._saveEditorViewState(e.editor));
|
||||
|
||||
if (!visible) {
|
||||
this._saveEditorViewState(this.input);
|
||||
if (this.input && this._widget.value) {
|
||||
// the widget is not transfered to other editor inputs
|
||||
this._widget.value.onWillHide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
focus() {
|
||||
|
||||
Reference in New Issue
Block a user