提交 11f838c1 编写于 作者: R rebornix

fix #112747.

上级 af92a731
......@@ -6,7 +6,7 @@
import 'vs/css!./media/notebookFind';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { IContextKeyService, IContextKey, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { KEYBINDING_CONTEXT_NOTEBOOK_FIND_WIDGET_FOCUSED, INotebookEditor, CellFindMatch, CellEditState, INotebookEditorContribution, NOTEBOOK_EDITOR_FOCUSED } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { KEYBINDING_CONTEXT_NOTEBOOK_FIND_WIDGET_FOCUSED, INotebookEditor, CellFindMatch, CellEditState, INotebookEditorContribution, NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_EDITOR_OPEN } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { FindDecorations } from 'vs/editor/contrib/find/findDecorations';
import { ModelDecorationOptions } from 'vs/editor/common/model/textModel';
import { IModelDeltaDecoration } from 'vs/editor/common/model';
......@@ -385,7 +385,7 @@ registerAction2(class extends Action2 {
id: 'notebook.find',
title: { value: localize('notebookActions.findInNotebook', "Find in Notebook"), original: 'Find in Notebook' },
keybinding: {
when: NOTEBOOK_EDITOR_FOCUSED,
when: ContextKeyExpr.or(NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_EDITOR_OPEN),
primary: KeyCode.KEY_F | KeyMod.CtrlCmd,
weight: KeybindingWeight.WorkbenchContrib
}
......
......@@ -31,12 +31,12 @@ import { NotebookEditorInput } from 'vs/workbench/contrib/notebook/browser/noteb
import { INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService';
import { NotebookService } from 'vs/workbench/contrib/notebook/browser/notebookServiceImpl';
import { CellKind, CellToolbarLocKey, CellUri, DisplayOrderKey, getCellUndoRedoComparisonKey, NotebookDocumentBackupData, NotebookEditorPriority, NotebookTextDiffEditorPreview, ShowCellStatusBarKey } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IEditorService, IOpenEditorOverride } from 'vs/workbench/services/editor/common/editorService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { CustomEditorsAssociations, customEditorsAssociationsSettingId } from 'vs/workbench/services/editor/common/editorOpenWith';
import { CustomEditorInfo } from 'vs/workbench/contrib/customEditor/common/customEditor';
import { INotebookEditor, NotebookEditorOptions } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { INotebookEditor, NotebookEditorOptions, NOTEBOOK_EDITOR_OPEN } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo';
import { INotebookEditorModelResolverService, NotebookModelResolverService } from 'vs/workbench/contrib/notebook/common/notebookEditorModelResolverService';
import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
......@@ -72,6 +72,7 @@ import 'vs/workbench/contrib/notebook/browser/diff/notebookDiffActions';
import 'vs/workbench/contrib/notebook/browser/view/output/transforms/streamTransform';
import 'vs/workbench/contrib/notebook/browser/view/output/transforms/errorTransform';
import 'vs/workbench/contrib/notebook/browser/view/output/transforms/richTransform';
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
/*--------------------------------------------------------------------------------------------- */
......@@ -204,17 +205,22 @@ Registry.as<IEditorInputFactoryRegistry>(EditorInputExtensions.EditorInputFactor
);
export class NotebookContribution extends Disposable implements IWorkbenchContribution {
private _notebookEditorIsOpen: IContextKey<boolean>;
constructor(
@IContextKeyService private readonly contextKeyService: IContextKeyService,
@IEditorService private readonly editorService: IEditorService,
@INotebookService private readonly notebookService: INotebookService,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IAccessibilityService private readonly _accessibilityService: IAccessibilityService,
@IEditorGroupsService private readonly editorGroupService: IEditorGroupsService,
@IUndoRedoService undoRedoService: IUndoRedoService,
) {
super();
this._notebookEditorIsOpen = NOTEBOOK_EDITOR_OPEN.bindTo(this.contextKeyService);
this._register(undoRedoService.registerUriComparisonKeyComputer(CellUri.scheme, {
getComparisonKey: (uri: URI): string => {
return getCellUndoRedoComparisonKey(uri);
......@@ -264,6 +270,18 @@ export class NotebookContribution extends Disposable implements IWorkbenchContri
this.notebookService.updateActiveNotebookEditor(null);
}
}));
this.editorGroupService.whenRestored.then(() => this._updateContextKeys());
this._register(this.editorService.onDidActiveEditorChange(() => this._updateContextKeys()));
this._register(this.editorService.onDidVisibleEditorsChange(() => this._updateContextKeys()));
this._register(this.editorGroupService.onDidAddGroup(() => this._updateContextKeys()));
this._register(this.editorGroupService.onDidRemoveGroup(() => this._updateContextKeys()));
}
private _updateContextKeys() {
const activeEditorPane = this.editorService.activeEditorPane as { isNotebookEditor?: boolean } | undefined;
this._notebookEditorIsOpen.set(!!activeEditorPane?.isNotebookEditor);
}
getUserAssociatedEditors(resource: URI) {
......
......@@ -39,6 +39,7 @@ export const NOTEBOOK_IS_ACTIVE_EDITOR = ContextKeyExpr.equals('activeEditor', '
// Editor keys
export const NOTEBOOK_EDITOR_FOCUSED = new RawContextKey<boolean>('notebookEditorFocused', false);
export const NOTEBOOK_EDITOR_OPEN = new RawContextKey<boolean>('notebookEditorOpen', false);
export const NOTEBOOK_CELL_LIST_FOCUSED = new RawContextKey<boolean>('notebookCellListFocused', false);
export const NOTEBOOK_OUTPUT_FOCUSED = new RawContextKey<boolean>('notebookOutputFocused', false);
export const NOTEBOOK_EDITOR_EDITABLE = new RawContextKey<boolean>('notebookEditable', true);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册