未验证 提交 ceff5053 编写于 作者: R rebornix

re #119706.

上级 ef80780f
......@@ -680,7 +680,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor
}
}
this._editorToolbarDisposable?.dispose();
this._editorToolbarDisposable.clear();
this._toolbarActionDisposable.clear();
}));
}
......@@ -702,7 +702,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor
private _toolbarActionDisposable = this._register(new DisposableStore());
private _topToolbar!: ToolBar;
private _useGlobalToolbar: boolean = false;
private _editorToolbarDisposable: IDisposable | null = null;
private _editorToolbarDisposable = this._register(new DisposableStore());
private _reigsterNotebookActionsToolbar() {
const cellMenu = this.instantiationService.createInstance(CellMenus);
this._notebookGlobalActionsMenu = this._register(cellMenu.getNotebookToolbar(this.scopedContextKeyService));
......@@ -748,10 +748,15 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor
}
private _showNotebookActionsinEditorToolbar() {
// when there is no view model, just ignore.
if (!this.viewModel) {
return;
}
if (!this._useGlobalToolbar) {
// schedule actions registration in next frame, otherwise we are seeing duplicated notbebook actions temporarily
this._editorToolbarDisposable?.dispose();
this._editorToolbarDisposable = DOM.scheduleAtNextAnimationFrame(() => {
this._editorToolbarDisposable.clear();
this._editorToolbarDisposable.add(DOM.scheduleAtNextAnimationFrame(() => {
const groups = this._notebookGlobalActionsMenu.getActions({ shouldForwardArgs: true });
this._toolbarActionDisposable.clear();
this._topToolbar.setActions([], []);
......@@ -759,10 +764,18 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor
return;
}
if (!this._isVisible || !this.hasFocus()) {
if (!this._isVisible) {
return;
}
if (this.editorService.activeEditorPane?.getId() === NOTEBOOK_EDITOR_ID) {
const notebookEditor = this.editorService.activeEditorPane.getControl() as INotebookEditor;
if (notebookEditor !== this) {
// clear actions but not recreate because it is not active editor
return;
}
}
groups.forEach(group => {
const groupName = group[0];
const actions = group[1];
......@@ -773,7 +786,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor
this._toolbarActionDisposable.add(MenuRegistry.appendMenuItem(MenuId.EditorTitle, {
command: {
id: menuItemAction.item.id,
title: menuItemAction.item.title + ' ' + this.viewModel?.uri.scheme,
title: menuItemAction.item.title,
category: menuItemAction.item.category,
tooltip: menuItemAction.item.tooltip,
icon: menuItemAction.item.icon,
......@@ -787,7 +800,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor
order++;
}
});
});
}));
this._notebookTopToolbarContainer.style.display = 'none';
} else {
......@@ -1463,7 +1476,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor
this.viewModel?.setFocus(focused);
if (!focused) {
this._editorToolbarDisposable?.dispose();
this._editorToolbarDisposable.clear();
this._toolbarActionDisposable.clear();
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册