Skip to content

Commit

Permalink
Merge pull request microsoft#163228 from amunger/IWFind
Browse files Browse the repository at this point in the history
enable find widget for interactive window
  • Loading branch information
amunger authored Oct 17, 2022
2 parents dfcbe89 + 9904d58 commit b4e1d3b
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import { INotebookEditorOptions } from 'vs/workbench/contrib/notebook/browser/no
import { NotebookEditorWidget } from 'vs/workbench/contrib/notebook/browser/notebookEditorWidget';
import * as icons from 'vs/workbench/contrib/notebook/browser/notebookIcons';
import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/services/notebookEditorService';
import { CellEditType, CellKind, CellUri, ICellOutput } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { CellEditType, CellKind, CellUri, ICellOutput, INTERACTIVE_WINDOW_EDITOR_ID } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { INotebookKernelService } from 'vs/workbench/contrib/notebook/common/notebookKernelService';
import { INotebookContentProvider, INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService';
import { columnToEditorGroup } from 'vs/workbench/services/editor/common/editorGroupColumn';
Expand All @@ -70,7 +70,7 @@ const interactiveWindowCategory: ILocalizedString = { value: localize('interacti
Registry.as<IEditorPaneRegistry>(EditorExtensions.EditorPane).registerEditorPane(
EditorPaneDescriptor.create(
InteractiveEditor,
InteractiveEditor.ID,
INTERACTIVE_WINDOW_EDITOR_ID,
'Interactive Window'
),
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ import { NOTEBOOK_KERNEL } from 'vs/workbench/contrib/notebook/common/notebookCo
import { ICursorPositionChangedEvent } from 'vs/editor/common/cursorEvents';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { isEqual } from 'vs/base/common/resources';
import { NotebookFindWidget } from 'vs/workbench/contrib/notebook/browser/contrib/find/notebookFindWidget';
import { INTERACTIVE_WINDOW_EDITOR_ID } from 'vs/workbench/contrib/notebook/common/notebookCommon';

const DECORATION_KEY = 'interactiveInputDecoration';
const INTERACTIVE_EDITOR_VIEW_STATE_PREFERENCE_KEY = 'InteractiveEditorViewState';
Expand All @@ -76,8 +78,6 @@ export interface InteractiveEditorOptions extends ITextEditorOptions {
}

export class InteractiveEditor extends EditorPane {
static readonly ID: string = 'workbench.editor.interactive';

#rootElement!: HTMLElement;
#styleElement!: HTMLStyleElement;
#notebookEditorContainer!: HTMLElement;
Expand Down Expand Up @@ -131,7 +131,7 @@ export class InteractiveEditor extends EditorPane {
@IExtensionService extensionService: IExtensionService,
) {
super(
InteractiveEditor.ID,
INTERACTIVE_WINDOW_EDITOR_ID,
telemetryService,
themeService,
storageService
Expand Down Expand Up @@ -328,7 +328,8 @@ export class InteractiveEditor extends EditorPane {
isReadOnly: true,
contributions: NotebookEditorExtensionsRegistry.getSomeEditorContributions([
ExecutionStateCellStatusBarContrib.id,
TimerCellStatusBarContrib.id
TimerCellStatusBarContrib.id,
NotebookFindWidget.id
]),
menuIds: {
notebookToolbar: MenuId.InteractiveToolbar,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export class FindModel extends Disposable {
} else {
const match = findMatch.matches[matchIndex] as FindMatch;
findMatch.cell.updateEditState(CellEditState.Editing, 'find');
findMatch.cell.isInputCollapsed = false;
this._notebookEditor.focusElement(findMatch.cell);
this._notebookEditor.setCellEditorSelection(findMatch.cell, match.range);
this._notebookEditor.revealRangeInCenterIfOutsideViewportAsync(findMatch.cell, match.range);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { IShowNotebookFindWidgetOptions, NotebookFindWidget } from 'vs/workbench
import { getNotebookEditorFromEditorPane } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { registerNotebookContribution } from 'vs/workbench/contrib/notebook/browser/notebookEditorExtensions';
import { CellUri } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { KEYBINDING_CONTEXT_NOTEBOOK_FIND_WIDGET_FOCUSED, NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_IS_ACTIVE_EDITOR } from 'vs/workbench/contrib/notebook/common/notebookContextKeys';
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';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { EditorOption } from 'vs/editor/common/config/editorOptions';

Expand Down Expand Up @@ -61,7 +61,7 @@ registerAction2(class extends Action2 {
id: 'notebook.find',
title: { value: localize('notebookActions.findInNotebook', "Find in Notebook"), original: 'Find in Notebook' },
keybinding: {
when: ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_IS_ACTIVE_EDITOR, EditorContextKeys.focus.toNegated()),
when: ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, ContextKeyExpr.or(NOTEBOOK_IS_ACTIVE_EDITOR, INTERACTIVE_WINDOW_IS_ACTIVE_EDITOR), EditorContextKeys.focus.toNegated()),
primary: KeyCode.KeyF | KeyMod.CtrlCmd,
weight: KeybindingWeight.WorkbenchContrib
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,24 +302,28 @@ export abstract class SimpleFindReplaceWidget extends Widget {
this._register(attachProgressBarStyler(this._progressBar, this._themeService));
this._domNode.appendChild(progressContainer);

const isInteractiveWindow = contextKeyService.getContextKeyValue('notebookType') === 'interactive';
// Toggle replace button
this._toggleReplaceBtn = this._register(new SimpleButton({
label: NLS_TOGGLE_REPLACE_MODE_BTN_LABEL,
className: 'codicon toggle left',
onTrigger: () => {
this._isReplaceVisible = !this._isReplaceVisible;
this._state.change({ isReplaceRevealed: this._isReplaceVisible }, false);
if (this._isReplaceVisible) {
this._innerReplaceDomNode.style.display = 'flex';
} else {
this._innerReplaceDomNode.style.display = 'none';
onTrigger: isInteractiveWindow ? () => { } :
() => {
this._isReplaceVisible = !this._isReplaceVisible;
this._state.change({ isReplaceRevealed: this._isReplaceVisible }, false);
if (this._isReplaceVisible) {
this._innerReplaceDomNode.style.display = 'flex';
} else {
this._innerReplaceDomNode.style.display = 'none';
}
}
}
}));
this._toggleReplaceBtn.setEnabled(!isInteractiveWindow);
this._toggleReplaceBtn.setExpanded(this._isReplaceVisible);
this._domNode.appendChild(this._toggleReplaceBtn.domNode);



this._innerFindDomNode = document.createElement('div');
this._innerFindDomNode.classList.add('simple-fr-find-part');

Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/contrib/notebook/common/notebookCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { IWorkingCopyBackupMeta, IWorkingCopySaveEvent } from 'vs/workbench/serv

export const NOTEBOOK_EDITOR_ID = 'workbench.editor.notebook';
export const NOTEBOOK_DIFF_EDITOR_ID = 'workbench.editor.notebookTextDiffEditor';
export const INTERACTIVE_WINDOW_EDITOR_ID = 'workbench.editor.interactive';


export enum CellKind {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
*--------------------------------------------------------------------------------------------*/

import { ContextKeyExpr, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
import { NOTEBOOK_EDITOR_ID } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { INTERACTIVE_WINDOW_EDITOR_ID, NOTEBOOK_EDITOR_ID } from 'vs/workbench/contrib/notebook/common/notebookCommon';



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

// Is Notebook
export const NOTEBOOK_IS_ACTIVE_EDITOR = ContextKeyExpr.equals('activeEditor', NOTEBOOK_EDITOR_ID);
export const INTERACTIVE_WINDOW_IS_ACTIVE_EDITOR = ContextKeyExpr.equals('activeEditor', INTERACTIVE_WINDOW_EDITOR_ID);

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

0 comments on commit b4e1d3b

Please sign in to comment.