Skip to content

Commit

Permalink
part of #4338
Browse files Browse the repository at this point in the history
  • Loading branch information
meganrogge committed Aug 7, 2024
1 parent 4a7a65c commit 157d708
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/vs/workbench/contrib/debug/browser/repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export class Repl extends FilterViewPane implements IHistoryNavigationWidget {
private multiSessionRepl: IContextKey<boolean>;
private menu: IMenu;
private replDataSource: IAsyncDataSource<IDebugSession, IReplElement> | undefined;
private findIsOpen: boolean = false;

constructor(
options: IViewPaneOptions,
Expand Down Expand Up @@ -348,6 +349,10 @@ export class Repl extends FilterViewPane implements IHistoryNavigationWidget {
this.filterWidget.focus();
}

openFind(): void {
this.tree?.openFind();
}

private setMode(): void {
if (!this.isVisible()) {
return;
Expand Down Expand Up @@ -664,7 +669,7 @@ export class Repl extends FilterViewPane implements IHistoryNavigationWidget {
accessibilityProvider: new ReplAccessibilityProvider(),
identityProvider,
mouseSupport: false,
findWidgetEnabled: false,
findWidgetEnabled: true,
keyboardNavigationLabelProvider: { getKeyboardNavigationLabel: (e: IReplElement) => e.toString(true) },
horizontalScrolling: !wordWrap,
setRowLineHeight: false,
Expand All @@ -689,11 +694,23 @@ export class Repl extends FilterViewPane implements IHistoryNavigationWidget {
}));

this._register(tree.onContextMenu(e => this.onContextMenu(e)));

this._register(tree.onDidChangeFindOpenState((open) => {
if (open) {
this.findIsOpen = true;
} else {
this.findIsOpen = false;
}
}));

let lastSelectedString: string;
this._register(tree.onMouseClick(() => {
if (this.findIsOpen) {
return;
}
const selection = dom.getWindow(this.treeContainer).getSelection();
if (!selection || selection.type !== 'Range' || lastSelectedString === selection.toString()) {
// only focus the input if the user is not currently selecting.
// only focus the input if the user is not currently selecting and find isn't open.
this.replInput.focus();
}
lastSelectedString = selection ? selection.toString() : '';
Expand Down
17 changes: 17 additions & 0 deletions src/vs/workbench/contrib/replNotebook/browser/repl.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ import { IInteractiveHistoryService } from 'vs/workbench/contrib/interactive/bro
import { NotebookEditorWidget } from 'vs/workbench/contrib/notebook/browser/notebookEditorWidget';
import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/services/notebookEditorService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { getReplView } from 'vs/workbench/contrib/debug/browser/repl';
import { REPL_VIEW_ID } from 'vs/workbench/contrib/debug/common/debug';
import { IViewsService } from 'vs/workbench/services/views/common/viewsService';
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';

type SerializedNotebookEditorData = { resource: URI; preferredResource: URI; viewType: string; options?: NotebookEditorInputOptions };
class ReplEditorSerializer implements IEditorSerializer {
Expand Down Expand Up @@ -257,3 +263,14 @@ export async function executeReplInput(accessor: ServicesAccessor, editorControl
}
}
}

KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'list.find.replInputFocus',
weight: KeybindingWeight.WorkbenchContrib + 1,
when: ContextKeyExpr.equals('view', REPL_VIEW_ID),
primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KeyF,
secondary: [KeyCode.F3],
handler: (accessor) => {
getReplView(accessor.get(IViewsService))?.openFind();
}
});

0 comments on commit 157d708

Please sign in to comment.