mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Merge pull request #163228 from amunger/IWFind
enable find widget for interactive window
This commit is contained in:
commit
b4e1d3b687
|
@ -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';
|
||||
|
@ -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'
|
||||
),
|
||||
[
|
||||
|
|
|
@ -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';
|
||||
|
@ -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;
|
||||
|
@ -131,7 +131,7 @@ export class InteractiveEditor extends EditorPane {
|
|||
@IExtensionService extensionService: IExtensionService,
|
||||
) {
|
||||
super(
|
||||
InteractiveEditor.ID,
|
||||
INTERACTIVE_WINDOW_EDITOR_ID,
|
||||
telemetryService,
|
||||
themeService,
|
||||
storageService
|
||||
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue