From 392aa77168254170ce87fe6c9ce951b3b27f4887 Mon Sep 17 00:00:00 2001 From: Megan Rogge Date: Fri, 2 Dec 2022 11:09:03 -0600 Subject: [PATCH] use correct icons for terminal opener quick fixes (#167946) --- .../browser/widgets/terminalQuickFixMenuItems.ts | 13 ++++++++----- .../contrib/terminal/browser/xterm/quickFixAddon.ts | 6 +++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/vs/workbench/contrib/terminal/browser/widgets/terminalQuickFixMenuItems.ts b/src/vs/workbench/contrib/terminal/browser/widgets/terminalQuickFixMenuItems.ts index 90b0c39b2e76d..fe7a3ef314430 100644 --- a/src/vs/workbench/contrib/terminal/browser/widgets/terminalQuickFixMenuItems.ts +++ b/src/vs/workbench/contrib/terminal/browser/widgets/terminalQuickFixMenuItems.ts @@ -3,12 +3,13 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { IAction } from 'vs/base/common/actions'; import { Codicon } from 'vs/base/common/codicons'; +import { Schemas } from 'vs/base/common/network'; import { CodeActionKind } from 'vs/editor/contrib/codeAction/common/types'; import { localize } from 'vs/nls'; import { ActionListItemKind, IListMenuItem } from 'vs/platform/actionWidget/browser/actionList'; import { IActionItem } from 'vs/platform/actionWidget/common/actionWidget'; +import { ITerminalAction } from 'vs/workbench/contrib/terminal/browser/xterm/quickFixAddon'; export const enum TerminalQuickFixType { Command = 'command', @@ -17,12 +18,12 @@ export const enum TerminalQuickFixType { } export class TerminalQuickFix implements IActionItem { - action: IAction; + action: ITerminalAction; type: string; disabled?: boolean; title?: string; source: string; - constructor(action: IAction, type: string, source: string, title?: string, disabled?: boolean) { + constructor(action: ITerminalAction, type: string, source: string, title?: string, disabled?: boolean) { this.action = action; this.disabled = disabled; this.title = title; @@ -62,8 +63,10 @@ export function toMenuItems(inputQuickFixes: readonly TerminalQuickFix[], showHe function getQuickFixIcon(quickFix: TerminalQuickFix): { codicon: Codicon } { switch (quickFix.type) { case TerminalQuickFixType.Opener: - // TODO: if it's a file link, use the open file icon - return { codicon: Codicon.link }; + if ('uri' in quickFix.action && quickFix.action.uri) { + const isUrl = (quickFix.action.uri.scheme === Schemas.http || quickFix.action.uri.scheme === Schemas.https); + return { codicon: isUrl ? Codicon.linkExternal : Codicon.goToFile }; + } case TerminalQuickFixType.Command: return { codicon: Codicon.run }; case TerminalQuickFixType.Port: diff --git a/src/vs/workbench/contrib/terminal/browser/xterm/quickFixAddon.ts b/src/vs/workbench/contrib/terminal/browser/xterm/quickFixAddon.ts index fa279da5917d9..103a05149804c 100644 --- a/src/vs/workbench/contrib/terminal/browser/xterm/quickFixAddon.ts +++ b/src/vs/workbench/contrib/terminal/browser/xterm/quickFixAddon.ts @@ -31,6 +31,7 @@ import { getLinesForCommand } from 'vs/platform/terminal/common/capabilities/com import { IAnchor } from 'vs/base/browser/ui/contextview/contextview'; import { ILabelService } from 'vs/platform/label/common/label'; import { Schemas } from 'vs/base/common/network'; +import { URI } from 'vs/base/common/uri'; const quickFixTelemetryTitle = 'terminal/quick-fix'; type QuickFixResultTelemetryEvent = { @@ -274,6 +275,8 @@ export class TerminalQuickFixAddon extends Disposable implements ITerminalAddon, export interface ITerminalAction extends IAction { source: string; + uri?: URI; + command?: string; } export async function getQuickFixesForCommand( @@ -350,7 +353,8 @@ export async function getQuickFixesForCommand( if (!fix.uri) { return; } - const uriLabel = (fix.uri.scheme === Schemas.http || fix.uri.scheme === Schemas.https) ? encodeURI(fix.uri.toString(true)) : labelService.getUriLabel(fix.uri); + const isUrl = (fix.uri.scheme === Schemas.http || fix.uri.scheme === Schemas.https); + const uriLabel = isUrl ? encodeURI(fix.uri.toString(true)) : labelService.getUriLabel(fix.uri); const label = localize('quickFix.opener', 'Open: {0}', uriLabel); action = { source: quickFix.source,