Fix #98036. update editor container focus when focus goes into detached notebook and outputs in webview.

This commit is contained in:
rebornix 2020-05-29 10:59:59 -07:00
parent 0780b5ef40
commit 89b16f2c7c
2 changed files with 18 additions and 2 deletions

View file

@ -6,7 +6,7 @@
import * as DOM from 'vs/base/browser/dom';
import { CancellationToken } from 'vs/base/common/cancellation';
import { Emitter, Event } from 'vs/base/common/event';
import { MutableDisposable } from 'vs/base/common/lifecycle';
import { MutableDisposable, DisposableStore } from 'vs/base/common/lifecycle';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
@ -29,6 +29,9 @@ export class NotebookEditor extends BaseEditor {
private _widget?: NotebookEditorWidget;
private _rootElement!: HTMLElement;
private dimension: DOM.Dimension | null = null;
private _widgetDisposableStore: DisposableStore = new DisposableStore();
private readonly _onDidFocusWidget = this._register(new Emitter<void>());
public get onDidFocus(): Event<any> { return this._onDidFocusWidget.event; }
constructor(
@ITelemetryService telemetryService: ITelemetryService,
@ -140,6 +143,7 @@ export class NotebookEditor extends BaseEditor {
}
});
this._widgetDisposableStore.clear();
const existingEditorWidgetForInput = NotebookRegistry.getNotebookEditorWidget(input);
if (existingEditorWidgetForInput) {
@ -166,6 +170,7 @@ export class NotebookEditor extends BaseEditor {
const viewState = this.loadTextEditorViewState(input);
this._widget.setModel(model.notebook, viewState, options);
this._widgetDisposableStore.add(this._widget.onDidFocus(() => this._onDidFocusWidget.fire()));
}
clearInput(): void {

View file

@ -93,6 +93,9 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor
private scrollBeyondLastLine: boolean;
private readonly memento: Memento;
private _isDisposed: boolean = false;
private readonly _onDidFocusWidget = this._register(new Emitter<void>());
public get onDidFocus(): Event<any> { return this._onDidFocusWidget.event; }
constructor(
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IStorageService storageService: IStorageService,
@ -341,6 +344,10 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor
}));
this._register(this.list.onDidChangeFocus(_e => this._onDidChangeActiveEditor.fire(this)));
const widgetFocusTracker = DOM.trackFocus(this.getDomNode());
this._register(widgetFocusTracker);
this._register(widgetFocusTracker.onDidFocus(() => this._onDidFocusWidget.fire()));
}
getDomNode() {
@ -462,7 +469,11 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor
this.webview = this.instantiationService.createInstance(BackLayerWebView, this, id, document);
await this.webview.waitForInitialization();
this.webview.webview.onDidBlur(() => this.updateEditorFocus());
this.webview.webview.onDidFocus(() => this.updateEditorFocus());
this.webview.webview.onDidFocus(() => {
this.updateEditorFocus();
this._onDidFocusWidget.fire();
});
this.localStore.add(this.webview.onMessage(message => {
if (this.viewModel) {
this.notebookService.onDidReceiveMessage(this.viewModel.viewType, this.getId(), message);