diff --git a/src/vs/workbench/contrib/codeEditor/browser/find/simpleFindWidget.ts b/src/vs/workbench/contrib/codeEditor/browser/find/simpleFindWidget.ts index d31078de..edf0d11f 100644 --- a/src/vs/workbench/contrib/codeEditor/browser/find/simpleFindWidget.ts +++ b/src/vs/workbench/contrib/codeEditor/browser/find/simpleFindWidget.ts @@ -196,6 +196,10 @@ export abstract class SimpleFindWidget extends Widget { return this._findInput.getValue(); } + public setInputValue(value: string) { + this._findInput.setValue(value); + } + public get focusTracker(): dom.IFocusTracker { return this._focusTracker; } diff --git a/src/vs/workbench/contrib/webview/browser/overlayWebview.ts b/src/vs/workbench/contrib/webview/browser/overlayWebview.ts index d9cb718c..b7461d1d 100644 --- a/src/vs/workbench/contrib/webview/browser/overlayWebview.ts +++ b/src/vs/workbench/contrib/webview/browser/overlayWebview.ts @@ -340,6 +340,13 @@ export class OverlayWebview extends Disposable implements IOverlayWebview { } } + public showFindWithArg(arg: string) { + if (this._webview.value) { + this._webview.value.showFindWithArg!(arg); + this._findWidgetVisible?.set(true); + } + } + hideFind() { this._findWidgetVisible?.reset(); this._webview.value?.hideFind(); diff --git a/src/vs/workbench/contrib/webview/browser/webview.ts b/src/vs/workbench/contrib/webview/browser/webview.ts index e9e90223..d03edeae 100644 --- a/src/vs/workbench/contrib/webview/browser/webview.ts +++ b/src/vs/workbench/contrib/webview/browser/webview.ts @@ -188,6 +188,7 @@ export interface IWebview extends IDisposable { reload(): void; showFind(): void; + showFindWithArg?(value: string): void; hideFind(): void; runFindAction(previous: boolean): void; diff --git a/src/vs/workbench/contrib/webview/browser/webviewElement.ts b/src/vs/workbench/contrib/webview/browser/webviewElement.ts index 77aaf668..4f8da29a 100644 --- a/src/vs/workbench/contrib/webview/browser/webviewElement.ts +++ b/src/vs/workbench/contrib/webview/browser/webviewElement.ts @@ -929,6 +929,11 @@ export class WebviewElement extends Disposable implements IWebview, WebviewFindD this._webviewFindWidget?.reveal(); } + public showFindWithArg(arg: string) { + this.showFind(); + this._webviewFindWidget?.setInputValue(arg); + } + public hideFind() { this._webviewFindWidget?.hide(); } diff --git a/src/vs/workbench/contrib/webviewPanel/browser/webviewCommands.ts b/src/vs/workbench/contrib/webviewPanel/browser/webviewCommands.ts index 95a869f9..3a0939ef 100644 --- a/src/vs/workbench/contrib/webviewPanel/browser/webviewCommands.ts +++ b/src/vs/workbench/contrib/webviewPanel/browser/webviewCommands.ts @@ -39,6 +39,26 @@ export class ShowWebViewEditorFindWidgetAction extends Action2 { } } +export class ShowWebViewEditorFindWidgetWithArgAction extends Action2 { + public static readonly ID = 'editor.action.webvieweditor.showFindWithArg'; + public static readonly LABEL = nls.localize('editor.action.webvieweditor.showFindWithArg', "Show find with argument"); + + constructor() { + super({ + id: ShowWebViewEditorFindWidgetWithArgAction.ID, + title: ShowWebViewEditorFindWidgetWithArgAction.LABEL, + keybinding: { + when: ContextKeyExpr.and(webviewActiveContextKeyExpr, KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_ENABLED), + weight: KeybindingWeight.EditorContrib + } + }); + } + + public run(accessor: ServicesAccessor, ...args: any[]): void { + getActiveWebviewEditor(accessor)?.showFindWithArg!(args[0] as string); + } +} + export class HideWebViewEditorFindCommand extends Action2 { public static readonly ID = 'editor.action.webvieweditor.hideFind'; public static readonly LABEL = nls.localize('editor.action.webvieweditor.hideFind', "Stop find"); diff --git a/src/vs/workbench/contrib/webviewPanel/browser/webviewPanel.contribution.ts b/src/vs/workbench/contrib/webviewPanel/browser/webviewPanel.contribution.ts index 9b9f5741..72f49c6e 100644 --- a/src/vs/workbench/contrib/webviewPanel/browser/webviewPanel.contribution.ts +++ b/src/vs/workbench/contrib/webviewPanel/browser/webviewPanel.contribution.ts @@ -16,7 +16,7 @@ import { EditorExtensions, IEditorFactoryRegistry } from 'vs/workbench/common/ed import { EditorInput } from 'vs/workbench/common/editor/editorInput'; import { IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService'; import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle'; -import { HideWebViewEditorFindCommand, ReloadWebviewAction, ShowWebViewEditorFindWidgetAction, WebViewEditorFindNextCommand, WebViewEditorFindPreviousCommand } from './webviewCommands'; +import { HideWebViewEditorFindCommand, ReloadWebviewAction, ShowWebViewEditorFindWidgetAction, ShowWebViewEditorFindWidgetWithArgAction, WebViewEditorFindNextCommand, WebViewEditorFindPreviousCommand } from './webviewCommands'; import { WebviewEditor } from './webviewEditor'; import { WebviewInput } from './webviewEditorInput'; import { WebviewEditorInputSerializer } from './webviewEditorInputSerializer'; @@ -91,6 +91,7 @@ Registry.as(EditorExtensions.EditorFactory).registerEdit registerSingleton(IWebviewWorkbenchService, WebviewEditorService, true); registerAction2(ShowWebViewEditorFindWidgetAction); +registerAction2(ShowWebViewEditorFindWidgetWithArgAction); registerAction2(HideWebViewEditorFindCommand); registerAction2(WebViewEditorFindNextCommand); registerAction2(WebViewEditorFindPreviousCommand);