Skip to content

Commit

Permalink
Use more explicit names for webview funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
mjbvz committed Sep 1, 2020
1 parent e6b0f45 commit 6fee049
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { EditorDescriptor, Extensions as EditorExtensions, IEditorRegistry } fro
import { Extensions as EditorInputExtensions, IEditorInputFactoryRegistry } from 'vs/workbench/common/editor';
import { Webview, WebviewOverlay } from 'vs/workbench/contrib/webview/browser/webview';
import { WebviewEditorInputFactory } from 'vs/workbench/contrib/webview/browser/webviewEditorInputFactory';
import { getActiveWebview, HideWebViewEditorFindCommand, ReloadWebviewAction, ShowWebViewEditorFindWidgetAction, WebViewEditorFindNextCommand, WebViewEditorFindPreviousCommand } from '../browser/webviewCommands';
import { getActiveWebviewEditor, HideWebViewEditorFindCommand, ReloadWebviewAction, ShowWebViewEditorFindWidgetAction, WebViewEditorFindNextCommand, WebViewEditorFindPreviousCommand } from '../browser/webviewCommands';
import { WebviewEditor } from './webviewEditor';
import { WebviewInput } from './webviewEditorInput';
import { IWebviewWorkbenchService, WebviewEditorService } from './webviewWorkbenchService';
Expand All @@ -38,8 +38,8 @@ registerAction2(WebViewEditorFindPreviousCommand);
registerAction2(ReloadWebviewAction);


function getActiveElectronBasedWebview(accessor: ServicesAccessor): Webview | undefined {
const webview = getActiveWebview(accessor);
function getInnerActiveWebview(accessor: ServicesAccessor): Webview | undefined {
const webview = getActiveWebviewEditor(accessor);
if (!webview) {
return undefined;
}
Expand All @@ -62,7 +62,7 @@ const PRIORITY = 100;

function overrideCommandForWebview(command: MultiCommand | undefined, f: (webview: Webview) => void) {
command?.addImplementation(PRIORITY, accessor => {
const webview = getActiveElectronBasedWebview(accessor);
const webview = getInnerActiveWebview(accessor);
if (webview && webview.isFocused) {
f(webview);
return true;
Expand Down
10 changes: 5 additions & 5 deletions src/vs/workbench/contrib/webview/browser/webviewCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class ShowWebViewEditorFindWidgetAction extends Action2 {
}

public run(accessor: ServicesAccessor): void {
getActiveWebview(accessor)?.showFind();
getActiveWebviewEditor(accessor)?.showFind();
}
}

Expand All @@ -54,7 +54,7 @@ export class HideWebViewEditorFindCommand extends Action2 {
}

public run(accessor: ServicesAccessor): void {
getActiveWebview(accessor)?.hideFind();
getActiveWebviewEditor(accessor)?.hideFind();
}
}

Expand All @@ -75,7 +75,7 @@ export class WebViewEditorFindNextCommand extends Action2 {
}

public run(accessor: ServicesAccessor): void {
getActiveWebview(accessor)?.runFindAction(false);
getActiveWebviewEditor(accessor)?.runFindAction(false);
}
}

Expand All @@ -96,7 +96,7 @@ export class WebViewEditorFindPreviousCommand extends Action2 {
}

public run(accessor: ServicesAccessor): void {
getActiveWebview(accessor)?.runFindAction(true);
getActiveWebviewEditor(accessor)?.runFindAction(true);
}
}

Expand Down Expand Up @@ -125,7 +125,7 @@ export class ReloadWebviewAction extends Action2 {
}
}

export function getActiveWebview(accessor: ServicesAccessor): Webview | undefined {
export function getActiveWebviewEditor(accessor: ServicesAccessor): Webview | undefined {
const editorService = accessor.get(IEditorService);
const activeEditor = editorService.activeEditor;
return activeEditor instanceof WebviewInput ? activeEditor.webview : undefined;
Expand Down

0 comments on commit 6fee049

Please sign in to comment.