@@ -29,7 +29,8 @@ import { ITerminalQuickFixProviderSelector, ITerminalQuickFixService } from 'vs/
29
29
import { ITerminalQuickFixOptions , IResolvedExtensionOptions , IUnresolvedExtensionOptions , ITerminalCommandSelector , ITerminalQuickFix , IInternalOptions , ITerminalQuickFixCommandAction , ITerminalQuickFixOpenerAction } from 'vs/platform/terminal/common/xterm/terminalQuickFix' ;
30
30
import { getLinesForCommand } from 'vs/platform/terminal/common/capabilities/commandDetectionCapability' ;
31
31
import { IAnchor } from 'vs/base/browser/ui/contextview/contextview' ;
32
- import { URI } from 'vs/base/common/uri' ;
32
+ import { ILabelService } from 'vs/platform/label/common/label' ;
33
+ import { Schemas } from 'vs/base/common/network' ;
33
34
34
35
const quickFixTelemetryTitle = 'terminal/quick-fix' ;
35
36
type QuickFixResultTelemetryEvent = {
@@ -81,7 +82,8 @@ export class TerminalQuickFixAddon extends Disposable implements ITerminalAddon,
81
82
@ILogService private readonly _logService : ILogService ,
82
83
@IExtensionService private readonly _extensionService : IExtensionService ,
83
84
@ITerminalContributionService private readonly _terminalContributionService : ITerminalContributionService ,
84
- @IActionWidgetService private readonly _actionWidgetService : IActionWidgetService
85
+ @IActionWidgetService private readonly _actionWidgetService : IActionWidgetService ,
86
+ @ILabelService private readonly _labelService : ILabelService
85
87
) {
86
88
super ( ) ;
87
89
const commandDetectionCapability = this . _capabilities . get ( TerminalCapability . CommandDetection ) ;
@@ -195,7 +197,7 @@ export class TerminalQuickFixAddon extends Disposable implements ITerminalAddon,
195
197
}
196
198
return provider . provideTerminalQuickFixes ( command , lines , { type : 'resolved' , commandLineMatcher : selector . commandLineMatcher , outputMatcher : selector . outputMatcher , exitStatus : selector . exitStatus , id : selector . id } , new CancellationTokenSource ( ) . token ) ;
197
199
} ;
198
- const result = await getQuickFixesForCommand ( aliases , terminal , command , this . _commandListeners , this . _openerService , this . _onDidRequestRerunCommand , resolver ) ;
200
+ const result = await getQuickFixesForCommand ( aliases , terminal , command , this . _commandListeners , this . _openerService , this . _labelService , this . _onDidRequestRerunCommand , resolver ) ;
199
201
if ( ! result ) {
200
202
return ;
201
203
}
@@ -280,6 +282,7 @@ export async function getQuickFixesForCommand(
280
282
terminalCommand : ITerminalCommand ,
281
283
quickFixOptions : Map < string , ITerminalQuickFixOptions [ ] > ,
282
284
openerService : IOpenerService ,
285
+ labelService : ILabelService ,
283
286
onDidRequestRerunCommand ?: Emitter < { command : string ; addNewLine ?: boolean } > ,
284
287
getResolvedFixes ?: ( selector : ITerminalQuickFixOptions , lines ?: string [ ] ) => Promise < ITerminalQuickFix | ITerminalQuickFix [ ] | undefined >
285
288
) : Promise < ITerminalAction [ ] | undefined > {
@@ -344,26 +347,18 @@ export async function getQuickFixesForCommand(
344
347
}
345
348
case TerminalQuickFixType . Opener : {
346
349
const fix = quickFix as ITerminalQuickFixOpenerAction ;
347
- const label = localize ( 'quickFix.opener' , 'Open: {0}' , fix . uri . toString ( ) ) ;
350
+ if ( ! fix . uri ) {
351
+ return ;
352
+ }
353
+ const uriLabel = ( fix . uri . scheme === Schemas . http || fix . uri . scheme === Schemas . https ) ? encodeURI ( fix . uri . toString ( true ) ) : labelService . getUriLabel ( fix . uri ) ;
354
+ const label = localize ( 'quickFix.opener' , 'Open: {0}' , uriLabel ) ;
348
355
action = {
349
356
source : quickFix . source ,
350
357
id : quickFix . id ,
351
358
label,
352
359
class : quickFix . type ,
353
360
enabled : true ,
354
- run : ( ) => {
355
- let uri : URI | undefined ;
356
- if ( URI . isUri ( fix . uri ) ) {
357
- uri = fix . uri ;
358
- } else if ( typeof fix . uri === 'string' ) {
359
- uri = URI . parse ( fix . uri ) ;
360
- }
361
-
362
- if ( ! uri ) {
363
- return ;
364
- }
365
- openerService . open ( uri ) ;
366
- } ,
361
+ run : ( ) => openerService . open ( fix . uri ) ,
367
362
tooltip : label ,
368
363
uri : fix . uri
369
364
} as ITerminalAction ;
0 commit comments