Skip to content

Commit 63dfa63

Browse files
committed
fix resolve an insider task
1 parent a1fe6ff commit 63dfa63

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

Extension/src/Debugger/configurationProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { CppBuildTask, CppBuildTaskDefinition } from '../LanguageServer/cppBuild
1111
import * as util from '../common';
1212
import * as fs from 'fs';
1313
import * as Telemetry from '../telemetry';
14-
import { cppBuildTaskProvider, CppSourceStr } from '../LanguageServer/extension';
14+
import { cppBuildTaskProvider, CppSourceStrPrefix } from '../LanguageServer/extension';
1515
import * as logger from '../logger';
1616
import * as nls from 'vscode-nls';
1717
import { IConfiguration, IConfigurationSnippet, DebuggerType, DebuggerEvent, MIConfigurations, WindowsConfigurations, WSLConfigurations, PipeTransportConfigurations, TaskConfigStatus } from './configurations';
@@ -297,7 +297,7 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
297297
const compilerName: string = path.basename(compilerPath);
298298
const newConfig: vscode.DebugConfiguration = { ...defaultConfig }; // Copy enumerables and properties
299299

300-
newConfig.name = CppSourceStr + ": " + compilerName + " " + this.buildAndDebugActiveFileStr();
300+
newConfig.name = CppSourceStrPrefix + compilerName + " " + this.buildAndDebugActiveFileStr();
301301
newConfig.preLaunchTask = task.name;
302302
if (newConfig.type === "cppdbg") {
303303
newConfig.externalConsole = false;

Extension/src/Debugger/configurations.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import * as os from 'os';
77
import * as nls from 'vscode-nls';
8+
import { CppSourceStrPrefix } from '../LanguageServer/extension';
89

910
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
1011
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
@@ -95,7 +96,6 @@ export interface IConfiguration {
9596
}
9697

9798
abstract class Configuration implements IConfiguration {
98-
public snippetPrefix = "C/C++: ";
9999

100100
public executable: string;
101101
public pipeProgram: string;
@@ -128,7 +128,7 @@ export class MIConfigurations extends Configuration {
128128
this.additionalProperties ? `,${os.EOL}\t${indentJsonString(this.additionalProperties)}` : ""]);
129129

130130
return {
131-
"label": this.snippetPrefix + name,
131+
"label": CppSourceStrPrefix + name,
132132
"description": localize("launch.with", "Launch with {0}.", this.MIMode).replace(/\"/g, "\\\""),
133133
"bodyText": body.trim(),
134134
"isInitialConfiguration": true,
@@ -146,7 +146,7 @@ export class MIConfigurations extends Configuration {
146146
this.additionalProperties ? `,${os.EOL}\t${indentJsonString(this.additionalProperties)}` : ""]);
147147

148148
return {
149-
"label": this.snippetPrefix + name,
149+
"label": CppSourceStrPrefix + name,
150150
"description": localize("attach.with", "Attach with {0}.", this.MIMode).replace(/\"/g, "\\\""),
151151
"bodyText": body.trim(),
152152
"debuggerType": DebuggerType.cppdbg
@@ -168,7 +168,7 @@ export class PipeTransportConfigurations extends Configuration {
168168
}`, [this.additionalProperties ? `,${os.EOL}\t${indentJsonString(this.additionalProperties)}` : ""]);
169169

170170
return {
171-
"label": this.snippetPrefix + name,
171+
"label": CppSourceStrPrefix + name,
172172
"description": localize("pipe.launch.with", "Pipe Launch with {0}.", this.MIMode).replace(/\"/g, "\\\""),
173173
"bodyText": body.trim(),
174174
"debuggerType": DebuggerType.cppdbg
@@ -186,7 +186,7 @@ export class PipeTransportConfigurations extends Configuration {
186186
\t"MIMode": "${this.MIMode}"{0}
187187
}`, [this.additionalProperties ? `,${os.EOL}\t${indentJsonString(this.additionalProperties)}` : ""]);
188188
return {
189-
"label": this.snippetPrefix + name,
189+
"label": CppSourceStrPrefix + name,
190190
"description": localize("pipe.attach.with", "Pipe Attach with {0}.", this.MIMode).replace(/\"/g, "\\\""),
191191
"bodyText": body.trim(),
192192
"debuggerType": DebuggerType.cppdbg
@@ -206,7 +206,7 @@ export class WindowsConfigurations extends Configuration {
206206
}`;
207207

208208
return {
209-
"label": this.snippetPrefix + name,
209+
"label": CppSourceStrPrefix + name,
210210
"description": localize("launch.with.vs.debugger", "Launch with the Visual Studio C/C++ debugger.").replace(/\"/g, "\\\""),
211211
"bodyText": body.trim(),
212212
"isInitialConfiguration": true,
@@ -224,7 +224,7 @@ export class WindowsConfigurations extends Configuration {
224224
}`;
225225

226226
return {
227-
"label": this.snippetPrefix + name,
227+
"label": CppSourceStrPrefix + name,
228228
"description": localize("attach.with.vs.debugger", "Attach to a process with the Visual Studio C/C++ debugger.").replace(/\"/g, "\\\""),
229229
"bodyText": body.trim(),
230230
"debuggerType": DebuggerType.cppvsdbg
@@ -247,7 +247,7 @@ export class WSLConfigurations extends Configuration {
247247
}`, [this.additionalProperties ? `,${os.EOL}\t${indentJsonString(this.additionalProperties)}` : ""]);
248248

249249
return {
250-
"label": this.snippetPrefix + name,
250+
"label": CppSourceStrPrefix + name,
251251
"description": localize("launch.bash.windows", "Launch in Bash on Windows using {0}.", this.MIMode).replace(/\"/g, "\\\""),
252252
"bodyText": body.trim(),
253253
"debuggerType": DebuggerType.cppdbg
@@ -264,7 +264,7 @@ export class WSLConfigurations extends Configuration {
264264
}`, [this.additionalProperties ? `,${os.EOL}\t${indentJsonString(this.additionalProperties)}` : ""]);
265265

266266
return {
267-
"label": this.snippetPrefix + name,
267+
"label": CppSourceStrPrefix + name,
268268
"description": localize("remote.attach.bash.windows", "Attach to a remote process running in Bash on Windows using {0}.", this.MIMode).replace(/\"/g, "\\\""),
269269
"bodyText": body.trim(),
270270
"debuggerType": DebuggerType.cppdbg

Extension/src/LanguageServer/cppBuildTaskProvider.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,13 @@ export class CppBuildTaskProvider implements TaskProvider {
5757

5858
public resolveInsiderTask(_task: CppBuildTask): CppBuildTask | undefined {
5959
const definition: CppBuildTaskDefinition = <any>_task.definition;
60+
definition.label = definition.label.replace(ext.CppSourceStrPrefix, "");
6061
_task = this.getTask(definition.command, false, definition.args ? definition.args : [], definition, _task.detail);
6162
return _task;
6263
}
6364

6465
// Generate tasks to build the current file based on the user's detected compilers, the user's compilerPath setting, and the current file's extension.
65-
public async getTasks(appendSourceToName: boolean): Promise<CppBuildTask[]> {
66+
public async getTasks(appendSourceToName: boolean = false): Promise<CppBuildTask[]> {
6667
const editor: TextEditor | undefined = window.activeTextEditor;
6768
const emptyTasks: CppBuildTask[] = [];
6869
if (!editor) {
@@ -170,8 +171,8 @@ export class CppBuildTaskProvider implements TaskProvider {
170171
if (!definition) {
171172
const isWindows: boolean = os.platform() === 'win32';
172173
const isMacARM64: boolean = (os.platform() === 'darwin' && os.arch() === 'arm64');
173-
const taskLabel: string = ((appendSourceToName && !compilerPathBase.startsWith(ext.CppSourceStr)) ?
174-
ext.CppSourceStr + ": " : "") + compilerPathBase + " " + localize("build_active_file", "build active file");
174+
const taskLabel: string = ((appendSourceToName && !compilerPathBase.startsWith(ext.CppSourceStrPrefix)) ?
175+
ext.CppSourceStrPrefix : "") + compilerPathBase + " " + localize("build_active_file", "build active file");
175176
const filePath: string = path.join('${fileDirname}', '${fileBasenameNoExtension}');
176177
const programName: string = isWindows ? filePath + '.exe' : filePath;
177178
let args: string[] = isCl ? ['/Zi', '/EHsc', '/nologo', '/Fe:', programName, '${file}'] : ['-fdiagnostics-color=always', '-g', '${file}', '-o', programName];

Extension/src/LanguageServer/extension.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFo
3030
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
3131
export const cppBuildTaskProvider: CppBuildTaskProvider = new CppBuildTaskProvider();
3232
export const CppSourceStr: string = "C/C++";
33+
export const CppSourceStrPrefix = "C/C++: "
3334

3435
let prevCrashFile: string;
3536
let clients: ClientCollection;
@@ -174,15 +175,15 @@ export async function activate(): Promise<void> {
174175
vscode.tasks.onDidStartTask(event => {
175176
getActiveClient().PauseCodeAnalysis();
176177
if (event.execution.task.definition.type === CppBuildTaskProvider.CppBuildScriptType
177-
|| event.execution.task.name.startsWith(CppSourceStr)) {
178+
|| event.execution.task.name.startsWith(CppSourceStrPrefix)) {
178179
telemetry.logLanguageServerEvent('buildTaskStarted');
179180
}
180181
});
181182

182183
vscode.tasks.onDidEndTask(event => {
183184
getActiveClient().ResumeCodeAnalysis();
184185
if (event.execution.task.definition.type === CppBuildTaskProvider.CppBuildScriptType
185-
|| event.execution.task.name.startsWith(CppSourceStr)) {
186+
|| event.execution.task.name.startsWith(CppSourceStrPrefix)) {
186187
telemetry.logLanguageServerEvent('buildTaskFinished');
187188
if (event.execution.task.scope !== vscode.TaskScope.Global && event.execution.task.scope !== vscode.TaskScope.Workspace) {
188189
const folder: vscode.WorkspaceFolder | undefined = event.execution.task.scope;

0 commit comments

Comments
 (0)