Skip to content
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
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,11 @@
"default": true,
"description": "Check if there is a newer version of Task on startup."
},
"doubleClickToRun": {
"type": "number",
"default": 500,
"description": "The double-click timeout for a task in the tree view. To disable double-click to run, set this to 0."
},
"tree": {
"type": "object",
"description": "Tree view configuration options.",
Expand Down
15 changes: 15 additions & 0 deletions src/services/taskfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class TaskfileService {
private lastTaskDir: string | undefined;
private lastTaskCliArgs: string | undefined;
private version: semver.SemVer | undefined;
private previousSelection: string | undefined;
private previousSelectionTimestamp: number | undefined;

private constructor() {
TaskfileService.outputChannel = vscode.window.createOutputChannel('Task');
Expand Down Expand Up @@ -291,6 +293,16 @@ class TaskfileService {
}

public async goToDefinition(task: Task, preview: boolean = false): Promise<void> {
const currentTime = Date.now();
const doubleClicked = this.previousSelection !== undefined && this.previousSelectionTimestamp !== undefined
&& this.previousSelection === task.name
&& (currentTime - this.previousSelectionTimestamp) < settings.doubleClickToRun;
if (doubleClicked) {
this.previousSelection = undefined;
this.previousSelectionTimestamp = undefined;
return this.runTask(task.name);
}

log.info(`Navigating to "${task.name}" definition in: "${task.location.taskfile}"`);

let position = new vscode.Position(task.location.line - 1, task.location.column - 1);
Expand All @@ -311,6 +323,9 @@ class TaskfileService {
} catch (err) {
log.error(err);
}

this.previousSelection = task.name;
this.previousSelectionTimestamp = currentTime;
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/utils/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Settings {
public path!: string;
public outputTo!: OutputTo;
public checkForUpdates!: boolean;
public doubleClickToRun!: number;
public tree!: TreeSettings;
public terminal!: TerminalSettings;

Expand All @@ -30,6 +31,7 @@ class Settings {
this.path = config.get("path") ?? "task";
this.outputTo = config.get("outputTo") ?? OutputTo.output;
this.checkForUpdates = config.get("checkForUpdates") ?? true;
this.doubleClickToRun = config.get("doubleClickToRun") ?? 500;
this.tree = new TreeSettings();
this.terminal = new TerminalSettings();
}
Expand Down
Loading