-
Notifications
You must be signed in to change notification settings - Fork 646
Add auto test
debug mode for launch.json (#1780)
#1832
Add auto test
debug mode for launch.json (#1780)
#1832
Conversation
src/goDebugConfiguration.ts
Outdated
let debugMode; | ||
let testFileRegExp = RegExp('.*_test\.go$', 'g'); | ||
const currentFileName = vscode.window.activeTextEditor.document.fileName; | ||
if (testFileRegExp.test(currentFileName)) { |
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.
Isnt it simpler with if (activeEditor.document.fileName.endsWith('_test.go'))
?
I have a tendency to avoid regex when possible.
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.
still using regex ...
check filename to get debug mode
8cea511
to
39b3d17
Compare
src/goDebugConfiguration.ts
Outdated
@@ -54,6 +54,12 @@ export class GoDebugConfigurationProvider implements vscode.DebugConfigurationPr | |||
debugConfiguration['dlvLoadConfig'] = dlvConfig['dlvLoadConfig']; | |||
} | |||
|
|||
if (activeEditor.document.fileName.endsWith('_test.go')) { |
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.
The activeEditor
can be null
src/goDebugConfiguration.ts
Outdated
if (activeEditor.document.fileName.endsWith('_test.go')) { | ||
debugConfiguration['mode'] = 'test'; | ||
} else { | ||
debugConfiguration['mode'] = 'debug'; |
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.
Do we really need the else here?
5395b14
to
21d2e08
Compare
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.
Perfect, Thanks!
Fixes #1780 |
use regex to check if the current file is for test