Skip to content

Commit 6261075

Browse files
authored
use different terminal ID (microsoft#165719)
1 parent b65a491 commit 6261075

File tree

4 files changed

+24
-15
lines changed

4 files changed

+24
-15
lines changed

src/vs/workbench/contrib/terminal/browser/terminal.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -968,12 +968,14 @@ export type TerminalQuickFixCallback = (matchResult: TerminalQuickFixMatchResult
968968

969969
export interface ITerminalQuickFixCommandAction {
970970
type: 'command';
971+
id: string;
971972
command: string;
972973
// TODO: Should this depend on whether alt is held?
973974
addNewLine: boolean;
974975
}
975976
export interface ITerminalQuickFixOpenerAction {
976977
type: 'opener';
978+
id: string;
977979
uri: URI;
978980
}
979981

src/vs/workbench/contrib/terminal/browser/terminalQuickFixBuiltinActions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export function gitSimilar(): ITerminalQuickFixOptions {
4040
const fixedCommand = results[i];
4141
if (fixedCommand) {
4242
actions.push({
43+
id: 'Git Similar',
4344
type: 'command',
4445
command: command.command.replace(/git\s+[^\s]+/, `git ${fixedCommand}`),
4546
addNewLine: true
@@ -70,6 +71,7 @@ export function gitTwoDashes(): ITerminalQuickFixOptions {
7071
}
7172
return {
7273
type: 'command',
74+
id: 'Git Two Dashes',
7375
command: command.command.replace(` -${problemArg}`, ` --${problemArg}`),
7476
addNewLine: true
7577
};

src/vs/workbench/contrib/terminal/browser/xterm/quickFixAddon.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ import { URI } from 'vs/base/common/uri';
3434
import { gitCreatePr, gitPushSetUpstream, gitSimilar } from 'vs/workbench/contrib/terminal/browser/terminalQuickFixBuiltinActions';
3535
const quickFixTelemetryTitle = 'terminal/quick-fix';
3636
type QuickFixResultTelemetryEvent = {
37-
id: string;
37+
quickFixId: string;
3838
fixesShown: boolean;
3939
ranQuickFixCommand?: boolean;
4040
};
4141
type QuickFixClassification = {
4242
owner: 'meganrogge';
43-
id: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The quick fix ID' };
43+
quickFixId: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The quick fix ID' };
4444
fixesShown: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Whether the fixes were shown by the user' };
4545
ranQuickFixCommand?: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'If the command that was executed matched a quick fix suggested one. Undefined if no command is expected.' };
4646
comment: 'Terminal quick fixes';
@@ -75,6 +75,7 @@ export class TerminalQuickFixAddon extends Disposable implements ITerminalAddon,
7575

7676
private _fixesShown: boolean = false;
7777
private _expectedCommands: string[] | undefined;
78+
private _fixId: string | undefined;
7879

7980
constructor(private readonly _capabilities: ITerminalCapabilityStore,
8081
@IContextMenuService private readonly _contextMenuService: IContextMenuService,
@@ -131,18 +132,20 @@ export class TerminalQuickFixAddon extends Disposable implements ITerminalAddon,
131132
}
132133
this._register(commandDetection.onCommandFinished(command => {
133134
if (this._expectedCommands) {
135+
const quickFixId = this._fixId || '';
134136
const ranQuickFixCommand = this._expectedCommands.includes(command.command);
135137
this._logService.debug(quickFixTelemetryTitle, {
136-
id: this._expectedCommands.join(' '),
138+
quickFixId,
137139
fixesShown: this._fixesShown,
138140
ranQuickFixCommand
139141
});
140142
this._telemetryService?.publicLog2<QuickFixResultTelemetryEvent, QuickFixClassification>(quickFixTelemetryTitle, {
141-
id: this._expectedCommands.join(' '),
143+
quickFixId,
142144
fixesShown: this._fixesShown,
143145
ranQuickFixCommand
144146
});
145147
this._expectedCommands = undefined;
148+
this._fixId = undefined;
146149
}
147150
this._resolveQuickFixes(command);
148151
this._fixesShown = false;
@@ -170,16 +173,17 @@ export class TerminalQuickFixAddon extends Disposable implements ITerminalAddon,
170173
}
171174
const { fixes, onDidRunQuickFix, expectedCommands } = result;
172175
this._expectedCommands = expectedCommands;
176+
this._fixId = fixes.map(f => f.id).join('');
173177
this._quickFixes = fixes;
174-
this._register(onDidRunQuickFix((id) => {
178+
this._register(onDidRunQuickFix((quickFixId) => {
175179
const ranQuickFixCommand = (this._expectedCommands?.includes(command.command) || false);
176180
this._logService.debug(quickFixTelemetryTitle, {
177-
id,
181+
quickFixId,
178182
fixesShown: this._fixesShown,
179183
ranQuickFixCommand
180184
});
181185
this._telemetryService?.publicLog2<QuickFixResultTelemetryEvent, QuickFixClassification>(quickFixTelemetryTitle, {
182-
id,
186+
quickFixId,
183187
fixesShown: this._fixesShown,
184188
ranQuickFixCommand
185189
});
@@ -270,7 +274,7 @@ export function getQuickFixesForCommand(
270274
case 'command': {
271275
const label = localize('quickFix.command', 'Run: {0}', quickFix.command);
272276
action = {
273-
id: `quickFix.command`,
277+
id: quickFix.id,
274278
label,
275279
class: undefined,
276280
enabled: true,
@@ -372,6 +376,7 @@ export function convertToQuickFixOptions(quickFix: IExtensionTerminalQuickFix):
372376
if (fixedCommand) {
373377
actions.push({
374378
type: 'command',
379+
id: quickFix.id,
375380
command: fixedCommand,
376381
addNewLine: true
377382
});

src/vs/workbench/contrib/terminal/test/browser/quickFixAddon.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ suite('QuickFixAddon', () => {
6161
status`;
6262
const exitCode = 1;
6363
const actions = [{
64-
id: `quickFix.command`,
64+
id: 'Git Similar',
6565
enabled: true,
6666
label: 'Run: git status',
6767
tooltip: 'Run: git status',
@@ -100,13 +100,13 @@ suite('QuickFixAddon', () => {
100100
pull
101101
push`;
102102
const actions = [{
103-
id: `quickFix.command`,
103+
id: 'Git Similar',
104104
enabled: true,
105105
label: 'Run: git pull',
106106
tooltip: 'Run: git pull',
107107
command: 'git pull'
108108
}, {
109-
id: `quickFix.command`,
109+
id: 'Git Similar',
110110
enabled: true,
111111
label: 'Run: git push',
112112
tooltip: 'Run: git push',
@@ -120,7 +120,7 @@ suite('QuickFixAddon', () => {
120120
The most similar commands are
121121
checkout`;
122122
assertMatchOptions(getQuickFixesForCommand(createCommand('git checkoutt .', output, GitSimilarOutputRegex), expectedMap, openerService)?.fixes, [{
123-
id: `quickFix.command`,
123+
id: 'Git Similar',
124124
enabled: true,
125125
label: 'Run: git checkout .',
126126
tooltip: 'Run: git checkout .',
@@ -135,7 +135,7 @@ suite('QuickFixAddon', () => {
135135
const output = 'error: did you mean `--all` (with two dashes)?';
136136
const exitCode = 1;
137137
const actions = [{
138-
id: `quickFix.command`,
138+
id: 'Git Two Dashes',
139139
enabled: true,
140140
label: 'Run: git add . --all',
141141
tooltip: 'Run: git add . --all',
@@ -213,7 +213,7 @@ suite('QuickFixAddon', () => {
213213
git push --set-upstream origin test22`;
214214
const exitCode = 128;
215215
const actions = [{
216-
id: `quickFix.command`,
216+
id: 'Git Push Set Upstream',
217217
enabled: true,
218218
label: 'Run: git push --set-upstream origin test22',
219219
tooltip: 'Run: git push --set-upstream origin test22',
@@ -292,7 +292,7 @@ suite('QuickFixAddon', () => {
292292
git push --set-upstream origin test22`;
293293
const exitCode = 128;
294294
const actions = [{
295-
id: `quickFix.command`,
295+
id: 'Git Push Set Upstream',
296296
enabled: true,
297297
label: 'Run: git push --set-upstream origin test22',
298298
tooltip: 'Run: git push --set-upstream origin test22',

0 commit comments

Comments
 (0)