Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix cpp task labels and ensure they can be run #6419

Merged
merged 1 commit into from
Oct 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/cpp/src/browser/cpp-task-provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe('CppTaskProvider', function (): void {

const resolvedTask = await taskProvider.resolveTask(tasks[0]);
expect(resolvedTask.type === 'shell');
expect((<ProcessTaskConfiguration>resolvedTask).cwd).to.be.equal('/tmp/build2');
expect((<ProcessTaskConfiguration>resolvedTask).options!.cwd).to.be.equal('/tmp/build2');
expect((<ProcessTaskConfiguration>resolvedTask).command).to.be.equal('very');
expect((<ProcessTaskConfiguration>resolvedTask).args).to.deep.equal(['complex', 'command']);
});
Expand Down
4 changes: 3 additions & 1 deletion packages/cpp/src/browser/cpp-task-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ export class CppTaskProvider implements TaskContribution, TaskProvider, TaskReso
type: 'shell',
command,
args,
cwd: task.config.directory,
options: {
cwd: task.config.directory,
}
};
return resolver.resolveTask(resolvedTask);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/task/src/browser/quick-open-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ export class TaskRunQuickOpenItem extends QuickOpenGroupItem {
}

if (this.taskDefinitionRegistry && !!this.taskDefinitionRegistry.getDefinition(this.task)) {
this.taskService.run(this.task.source, this.task.label);
this.taskService.run(this.task.source || this.task._source, this.task.label);
} else {
this.taskService.run(this.task._source, this.task.label);
}
Expand Down
10 changes: 7 additions & 3 deletions packages/task/src/browser/task-name-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
********************************************************************************/

import { inject, injectable } from 'inversify';
import { TaskConfiguration } from '../common';
import { TaskConfiguration, ContributedTaskConfiguration } from '../common';
import { TaskDefinitionRegistry } from './task-definition-registry';

@injectable()
Expand All @@ -28,11 +28,15 @@ export class TaskNameResolver {
* It is aligned with VS Code.
*/
resolve(task: TaskConfiguration): string {
if (this.taskDefinitionRegistry.getDefinition(task)) {
return `${task.source}: ${task.label}`;
if (this.isDetectedTask(task)) {
return `${task.source || task._source}: ${task.label}`;
}

// it is a hack, when task is customized but extension is absent
return task.label || `${task.type}: ${task.task}`;
}

private isDetectedTask(task: TaskConfiguration): task is ContributedTaskConfiguration {
return !!this.taskDefinitionRegistry.getDefinition(task);
}
}