File tree Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 293
293
"default" : true ,
294
294
"description" : " Check if there is a newer version of Task on startup."
295
295
},
296
+ "doubleClickToRun" : {
297
+ "type" : " number" ,
298
+ "default" : 500 ,
299
+ "description" : " The double-click timeout for a task in the tree view. To disable double-click to run, set this to 0."
300
+ },
296
301
"tree" : {
297
302
"type" : " object" ,
298
303
"description" : " Tree view configuration options." ,
Original file line number Diff line number Diff line change @@ -38,6 +38,8 @@ class TaskfileService {
38
38
private lastTaskName : string | undefined ;
39
39
private lastTaskDir : string | undefined ;
40
40
private version : semver . SemVer | undefined ;
41
+ private previousSelection : string | undefined ;
42
+ private previousSelectionTimestamp : number | undefined ;
41
43
42
44
private constructor ( ) {
43
45
TaskfileService . outputChannel = vscode . window . createOutputChannel ( 'Task' ) ;
@@ -280,6 +282,16 @@ class TaskfileService {
280
282
}
281
283
282
284
public async goToDefinition ( task : models . Task , preview : boolean = false ) : Promise < void > {
285
+ const currentTime = Date . now ( ) ;
286
+ const doubleClicked = this . previousSelection !== undefined && this . previousSelectionTimestamp !== undefined
287
+ && this . previousSelection === task . name
288
+ && ( currentTime - this . previousSelectionTimestamp ) < settings . doubleClickToRun ;
289
+ if ( doubleClicked ) {
290
+ this . previousSelection = undefined ;
291
+ this . previousSelectionTimestamp = undefined ;
292
+ return this . runTask ( task . name ) ;
293
+ }
294
+
283
295
log . info ( `Navigating to "${ task . name } " definition in: "${ task . location . taskfile } "` ) ;
284
296
285
297
let position = new vscode . Position ( task . location . line - 1 , task . location . column - 1 ) ;
@@ -300,6 +312,9 @@ class TaskfileService {
300
312
} catch ( err ) {
301
313
log . error ( err ) ;
302
314
}
315
+
316
+ this . previousSelection = task . name ;
317
+ this . previousSelectionTimestamp = currentTime ;
303
318
}
304
319
}
305
320
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ class Settings {
7
7
public path ! : string ;
8
8
public outputTo ! : OutputTo ;
9
9
public checkForUpdates ! : boolean ;
10
+ public doubleClickToRun ! : number ;
10
11
public tree ! : TreeSettings ;
11
12
public terminal ! : TerminalSettings ;
12
13
@@ -30,6 +31,7 @@ class Settings {
30
31
this . path = config . get ( "path" ) ?? "task" ;
31
32
this . outputTo = config . get ( "outputTo" ) ?? OutputTo . output ;
32
33
this . checkForUpdates = config . get ( "checkForUpdates" ) ?? true ;
34
+ this . doubleClickToRun = config . get ( "doubleClickToRun" ) ?? 500 ;
33
35
this . tree = new TreeSettings ( ) ;
34
36
this . terminal = new TerminalSettings ( ) ;
35
37
}
You can’t perform that action at this time.
0 commit comments