Skip to content

Commit 09ccca1

Browse files
committed
enable find widget for interactive window
1 parent d39c1b3 commit 09ccca1

File tree

6 files changed

+25
-17
lines changed

6 files changed

+25
-17
lines changed

src/vs/workbench/contrib/interactive/browser/interactive.contribution.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ import { INotebookEditorOptions } from 'vs/workbench/contrib/notebook/browser/no
5656
import { NotebookEditorWidget } from 'vs/workbench/contrib/notebook/browser/notebookEditorWidget';
5757
import * as icons from 'vs/workbench/contrib/notebook/browser/notebookIcons';
5858
import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/services/notebookEditorService';
59-
import { CellEditType, CellKind, CellUri, ICellOutput } from 'vs/workbench/contrib/notebook/common/notebookCommon';
59+
import { CellEditType, CellKind, CellUri, ICellOutput, INTERACTIVE_WINDOW_EDITOR_ID } from 'vs/workbench/contrib/notebook/common/notebookCommon';
6060
import { INotebookKernelService } from 'vs/workbench/contrib/notebook/common/notebookKernelService';
6161
import { INotebookContentProvider, INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService';
6262
import { columnToEditorGroup } from 'vs/workbench/services/editor/common/editorGroupColumn';
@@ -70,7 +70,7 @@ const interactiveWindowCategory: ILocalizedString = { value: localize('interacti
7070
Registry.as<IEditorPaneRegistry>(EditorExtensions.EditorPane).registerEditorPane(
7171
EditorPaneDescriptor.create(
7272
InteractiveEditor,
73-
InteractiveEditor.ID,
73+
INTERACTIVE_WINDOW_EDITOR_ID,
7474
'Interactive Window'
7575
),
7676
[

src/vs/workbench/contrib/interactive/browser/interactiveEditor.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ import { NOTEBOOK_KERNEL } from 'vs/workbench/contrib/notebook/common/notebookCo
5858
import { ICursorPositionChangedEvent } from 'vs/editor/common/cursorEvents';
5959
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
6060
import { isEqual } from 'vs/base/common/resources';
61+
import { NotebookFindWidget } from 'vs/workbench/contrib/notebook/browser/contrib/find/notebookFindWidget';
62+
import { INTERACTIVE_WINDOW_EDITOR_ID } from 'vs/workbench/contrib/notebook/common/notebookCommon';
6163

6264
const DECORATION_KEY = 'interactiveInputDecoration';
6365
const INTERACTIVE_EDITOR_VIEW_STATE_PREFERENCE_KEY = 'InteractiveEditorViewState';
@@ -76,8 +78,6 @@ export interface InteractiveEditorOptions extends ITextEditorOptions {
7678
}
7779

7880
export class InteractiveEditor extends EditorPane {
79-
static readonly ID: string = 'workbench.editor.interactive';
80-
8181
#rootElement!: HTMLElement;
8282
#styleElement!: HTMLStyleElement;
8383
#notebookEditorContainer!: HTMLElement;
@@ -131,7 +131,7 @@ export class InteractiveEditor extends EditorPane {
131131
@IExtensionService extensionService: IExtensionService,
132132
) {
133133
super(
134-
InteractiveEditor.ID,
134+
INTERACTIVE_WINDOW_EDITOR_ID,
135135
telemetryService,
136136
themeService,
137137
storageService
@@ -328,7 +328,8 @@ export class InteractiveEditor extends EditorPane {
328328
isReadOnly: true,
329329
contributions: NotebookEditorExtensionsRegistry.getSomeEditorContributions([
330330
ExecutionStateCellStatusBarContrib.id,
331-
TimerCellStatusBarContrib.id
331+
TimerCellStatusBarContrib.id,
332+
NotebookFindWidget.id
332333
]),
333334
menuIds: {
334335
notebookToolbar: MenuId.InteractiveToolbar,

src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFind.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { IShowNotebookFindWidgetOptions, NotebookFindWidget } from 'vs/workbench
2222
import { getNotebookEditorFromEditorPane } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
2323
import { registerNotebookContribution } from 'vs/workbench/contrib/notebook/browser/notebookEditorExtensions';
2424
import { CellUri } from 'vs/workbench/contrib/notebook/common/notebookCommon';
25-
import { KEYBINDING_CONTEXT_NOTEBOOK_FIND_WIDGET_FOCUSED, NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_IS_ACTIVE_EDITOR } from 'vs/workbench/contrib/notebook/common/notebookContextKeys';
25+
import { INTERACTIVE_WINDOW_IS_ACTIVE_EDITOR, KEYBINDING_CONTEXT_NOTEBOOK_FIND_WIDGET_FOCUSED, NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_IS_ACTIVE_EDITOR } from 'vs/workbench/contrib/notebook/common/notebookContextKeys';
2626
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
2727
import { EditorOption } from 'vs/editor/common/config/editorOptions';
2828

@@ -61,7 +61,7 @@ registerAction2(class extends Action2 {
6161
id: 'notebook.find',
6262
title: { value: localize('notebookActions.findInNotebook', "Find in Notebook"), original: 'Find in Notebook' },
6363
keybinding: {
64-
when: ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_IS_ACTIVE_EDITOR, EditorContextKeys.focus.toNegated()),
64+
when: ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, ContextKeyExpr.or(NOTEBOOK_IS_ACTIVE_EDITOR, INTERACTIVE_WINDOW_IS_ACTIVE_EDITOR), EditorContextKeys.focus.toNegated()),
6565
primary: KeyCode.KeyF | KeyMod.CtrlCmd,
6666
weight: KeybindingWeight.WorkbenchContrib
6767
}

src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindReplaceWidget.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -302,24 +302,28 @@ export abstract class SimpleFindReplaceWidget extends Widget {
302302
this._register(attachProgressBarStyler(this._progressBar, this._themeService));
303303
this._domNode.appendChild(progressContainer);
304304

305+
const isInteractiveWindow = contextKeyService.getContextKeyValue('notebookType') === 'interactive';
305306
// Toggle replace button
306307
this._toggleReplaceBtn = this._register(new SimpleButton({
307308
label: NLS_TOGGLE_REPLACE_MODE_BTN_LABEL,
308309
className: 'codicon toggle left',
309-
onTrigger: () => {
310-
this._isReplaceVisible = !this._isReplaceVisible;
311-
this._state.change({ isReplaceRevealed: this._isReplaceVisible }, false);
312-
if (this._isReplaceVisible) {
313-
this._innerReplaceDomNode.style.display = 'flex';
314-
} else {
315-
this._innerReplaceDomNode.style.display = 'none';
310+
onTrigger: isInteractiveWindow ? () => { } :
311+
() => {
312+
this._isReplaceVisible = !this._isReplaceVisible;
313+
this._state.change({ isReplaceRevealed: this._isReplaceVisible }, false);
314+
if (this._isReplaceVisible) {
315+
this._innerReplaceDomNode.style.display = 'flex';
316+
} else {
317+
this._innerReplaceDomNode.style.display = 'none';
318+
}
316319
}
317-
}
318320
}));
321+
this._toggleReplaceBtn.setEnabled(!isInteractiveWindow);
319322
this._toggleReplaceBtn.setExpanded(this._isReplaceVisible);
320323
this._domNode.appendChild(this._toggleReplaceBtn.domNode);
321324

322325

326+
323327
this._innerFindDomNode = document.createElement('div');
324328
this._innerFindDomNode.classList.add('simple-fr-find-part');
325329

src/vs/workbench/contrib/notebook/common/notebookCommon.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { IWorkingCopyBackupMeta, IWorkingCopySaveEvent } from 'vs/workbench/serv
3232

3333
export const NOTEBOOK_EDITOR_ID = 'workbench.editor.notebook';
3434
export const NOTEBOOK_DIFF_EDITOR_ID = 'workbench.editor.notebookTextDiffEditor';
35+
export const INTERACTIVE_WINDOW_EDITOR_ID = 'workbench.editor.interactive';
3536

3637

3738
export enum CellKind {

src/vs/workbench/contrib/notebook/common/notebookContextKeys.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { ContextKeyExpr, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
7-
import { NOTEBOOK_EDITOR_ID } from 'vs/workbench/contrib/notebook/common/notebookCommon';
7+
import { INTERACTIVE_WINDOW_EDITOR_ID, NOTEBOOK_EDITOR_ID } from 'vs/workbench/contrib/notebook/common/notebookCommon';
8+
89

910

1011
//#region Context Keys
@@ -13,6 +14,7 @@ export const KEYBINDING_CONTEXT_NOTEBOOK_FIND_WIDGET_FOCUSED = new RawContextKey
1314

1415
// Is Notebook
1516
export const NOTEBOOK_IS_ACTIVE_EDITOR = ContextKeyExpr.equals('activeEditor', NOTEBOOK_EDITOR_ID);
17+
export const INTERACTIVE_WINDOW_IS_ACTIVE_EDITOR = ContextKeyExpr.equals('activeEditor', INTERACTIVE_WINDOW_EDITOR_ID);
1618

1719
// Editor keys
1820
export const NOTEBOOK_EDITOR_FOCUSED = new RawContextKey<boolean>('notebookEditorFocused', false);

0 commit comments

Comments
 (0)