Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add find keyboard binding for help view #6526

Merged
merged 1 commit into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add find keyboard binding for help view
Displays help view find widget with ctrl+f
  • Loading branch information
timtmok committed Feb 27, 2025
commit 538f727773917bcecfd46e4ca96a3d7738dde6b5
17 changes: 16 additions & 1 deletion src/vs/workbench/contrib/positronHelp/browser/helpEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Disposable } from '../../../../base/common/lifecycle.js';
import { Emitter, Event } from '../../../../base/common/event.js';
import { IThemeService } from '../../../../platform/theme/common/themeService.js';
import { PositronHelpFocused } from '../../../common/contextkeys.js';
import { IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js';
import { IContextKey, IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js';
import { isLocalhost } from './utils.js';
import { ExtensionIdentifier } from '../../../../platform/extensions/common/extensions.js';
import { KeyEvent } from '../../webview/browser/webviewMessages.js';
Expand Down Expand Up @@ -270,6 +270,11 @@ export class HelpEntry extends Disposable implements IHelpEntry, WebviewFindDele
*/
private _claimTimeout?: NodeJS.Timeout;

/**
* The helpFocusedContextKey to track when the help overlay webview is focused.
*/
private helpFocusedContextKey: IContextKey<boolean>;

/**
* Gets or sets the dispose timeout. This timeout is used to schedule the disposal of the help
* overlay webview.
Expand Down Expand Up @@ -349,6 +354,8 @@ export class HelpEntry extends Disposable implements IHelpEntry, WebviewFindDele
// Reload the help overlay webview.
this._helpOverlayWebview?.reload();
}));

this.helpFocusedContextKey = PositronHelpFocused.bindTo(this._contextKeyService);
}

/**
Expand Down Expand Up @@ -620,6 +627,14 @@ export class HelpEntry extends Disposable implements IHelpEntry, WebviewFindDele
helpOverlayWebview.claim(element, DOM.getWindow(element), undefined);
helpOverlayWebview.layoutWebviewOverElement(element);

helpOverlayWebview.onDidFocus(() => {
this.helpFocusedContextKey.set(true);
});

helpOverlayWebview.onDidBlur(() => {
this.helpFocusedContextKey.set(false);
});

// Run logic for animating cases.
ensureWebviewSizeCorrectWhenAnimating();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { SyncDescriptor } from '../../../../platform/instantiation/common/descri
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
import { ViewPaneContainer } from '../../../browser/parts/views/viewPaneContainer.js';
import { PositronHelpView } from './positronHelpView.js';
import { POSITRON_HELP_VIEW_ID } from './positronHelpService.js';
import { POSITRON_HELP_COPY } from './positronHelpIdentifiers.js';
import { IPositronHelpService, POSITRON_HELP_VIEW_ID } from './positronHelpService.js';
import { POSITRON_HELP_COPY, POSITRON_HELP_FIND } from './positronHelpIdentifiers.js';
import { ICommandAndKeybindingRule, KeybindingWeight, KeybindingsRegistry } from '../../../../platform/keybinding/common/keybindingsRegistry.js';
import { IWorkbenchContribution, WorkbenchPhase, registerWorkbenchContribution2 } from '../../../common/contributions.js';
import { ViewContainer, IViewContainersRegistry, ViewContainerLocation, Extensions as ViewContainerExtensions, IViewsRegistry } from '../../../common/views.js';
Expand Down Expand Up @@ -77,7 +77,15 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
handler: accessor => { }
} satisfies ICommandAndKeybindingRule);


KeybindingsRegistry.registerCommandAndKeybindingRule({
id: POSITRON_HELP_FIND,
weight: KeybindingWeight.WorkbenchContrib,
primary: KeyMod.CtrlCmd | KeyCode.KeyF,
when: PositronHelpFocused,
handler: accessor => {
accessor.get(IPositronHelpService).find();
}
} satisfies ICommandAndKeybindingRule);

class PositronHelpContribution extends Disposable implements IWorkbenchContribution {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@

// Identifiers.
export const POSITRON_HELP_COPY = 'positron.help.copy';
export const POSITRON_HELP_FIND = 'positron.help.find';
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ export interface IPositronHelpService {
* Navigates forward.
*/
navigateForward(): void;

/**
* Show the find widget.
*/
find(): void;
}

/**
Expand Down Expand Up @@ -384,6 +389,13 @@ class PositronHelpService extends Disposable implements IPositronHelpService {
}
}

/**
* Show the find widget.
*/
find() {
this.currentHelpEntry.showFind();
}

//#endregion IPositronHelpService

//#region Private Methods
Expand Down