-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add task#runOptions
to API.
#11759
Add task#runOptions
to API.
#11759
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,13 +87,18 @@ export interface TaskEndedInfo { | |
value: number | boolean | undefined | ||
} | ||
|
||
export interface LastRunTaskInfo { | ||
resolvedTask?: TaskConfiguration; | ||
option?: RunTaskOption | ||
} | ||
|
||
@injectable() | ||
export class TaskService implements TaskConfigurationClient { | ||
|
||
/** | ||
* The last executed task. | ||
*/ | ||
protected lastTask: { source: string, taskLabel: string, scope: TaskConfigurationScope } | undefined = undefined; | ||
protected lastTask: LastRunTaskInfo = {resolvedTask: undefined, option: undefined}; | ||
protected cachedRecentTasks: TaskConfiguration[] = []; | ||
protected runningTasks = new Map<number, { | ||
exitCode: Deferred<number | undefined>, | ||
|
@@ -470,7 +475,7 @@ export class TaskService implements TaskConfigurationClient { | |
* | ||
* @returns the last executed task or `undefined`. | ||
*/ | ||
getLastTask(): { source: string, taskLabel: string, scope: TaskConfigurationScope } | undefined { | ||
getLastTask(): LastRunTaskInfo { | ||
return this.lastTask; | ||
} | ||
|
||
|
@@ -496,11 +501,14 @@ export class TaskService implements TaskConfigurationClient { | |
* @param token The cache token for the user interaction in progress | ||
*/ | ||
async runLastTask(token: number): Promise<TaskInfo | undefined> { | ||
if (!this.lastTask) { | ||
if (!this.lastTask?.resolvedTask) { | ||
return; | ||
} | ||
const { source, taskLabel, scope } = this.lastTask; | ||
return this.run(token, source, taskLabel, scope); | ||
if (!this.lastTask.resolvedTask.runOptions?.reevaluateOnRerun) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It appears that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes i was wondering this as well. I would find it odd, if the default behavior is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @colin-grant-work by "internal", do you mean tasks defined in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re: One solution might be to modify the plugin system to supply There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought about this some more: what I really would like to avoid is a "if tasksource = plugin, do x, else do y". I'm also not a fan of setting variables that are client API in order to simulate the "right" default behaviour: if anything, we should set a flag : There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm fine with this approach. |
||
return this.runResolvedTask(this.lastTask.resolvedTask, this.lastTask.option); | ||
} | ||
const { _source, label, _scope } = this.lastTask.resolvedTask; | ||
return this.run(token, _source, label, _scope); | ||
} | ||
|
||
/** | ||
|
@@ -737,7 +745,7 @@ export class TaskService implements TaskConfigurationClient { | |
try { | ||
// resolve problemMatchers | ||
if (!option && task.problemMatcher) { | ||
const customizationObject: TaskCustomization = { type: task.taskType, problemMatcher: task.problemMatcher }; | ||
const customizationObject: TaskCustomization = { type: task.taskType, problemMatcher: task.problemMatcher, runOptions: task.runOptions }; | ||
const resolvedMatchers = await this.resolveProblemMatchers(task, customizationObject); | ||
option = { | ||
customization: { ...customizationObject, ...{ problemMatcher: resolvedMatchers } } | ||
|
@@ -949,7 +957,7 @@ export class TaskService implements TaskConfigurationClient { | |
} | ||
|
||
protected async getTaskCustomization(task: TaskConfiguration): Promise<TaskCustomization> { | ||
const customizationObject: TaskCustomization = { type: '', _scope: task._scope }; | ||
const customizationObject: TaskCustomization = { type: '', _scope: task._scope, runOptions: task.runOptions }; | ||
const customizationFound = this.taskConfigurations.getCustomizationForTask(task); | ||
if (customizationFound) { | ||
Object.assign(customizationObject, customizationFound); | ||
|
@@ -982,12 +990,11 @@ export class TaskService implements TaskConfigurationClient { | |
* @param option options to run the resolved task | ||
*/ | ||
protected async runResolvedTask(resolvedTask: TaskConfiguration, option?: RunTaskOption): Promise<TaskInfo | undefined> { | ||
const source = resolvedTask._source; | ||
const taskLabel = resolvedTask.label; | ||
let taskInfo: TaskInfo | undefined; | ||
try { | ||
taskInfo = await this.taskServer.run(resolvedTask, this.getContext(), option); | ||
this.lastTask = { source, taskLabel, scope: resolvedTask._scope }; | ||
this.lastTask = {resolvedTask, option }; | ||
this.logger.debug(`Task created. Task id: ${taskInfo.taskId}`); | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As suggested by @tsmaeder, please add a note about the change in behavior for tasks in the breaking changes area.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Could you recheck?