debug: Clarify comments about noDebug mode

Change-Id: I65300b23e3a45d86478b4719a300b0b9e75b73c2
GitHub-Last-Rev: c88c51d229f834c01f661155338283366e939e54
GitHub-Pull-Request: golang/vscode-go#337
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/242277
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/src/debugAdapter2/goDlvDebug.ts b/src/debugAdapter2/goDlvDebug.ts
index 9937eae..6e213bbc 100644
--- a/src/debugAdapter2/goDlvDebug.ts
+++ b/src/debugAdapter2/goDlvDebug.ts
@@ -199,11 +199,11 @@
 		logger.setup(this.logLevel, logPath);
 		log('launchRequest');
 
-		// In noDebug mode, we don't launch Delve.
-		// TODO: this logic is currently organized for compatibility with the
-		// existing DA. It's not clear what we should do in case noDebug is
-		// set and mode isn't 'debug'. Sending an error response could be
-		// a safe option.
+		// In noDebug mode with the 'debug' launch mode, we don't launch Delve
+		// but run the debugee directly.
+		// For other launch modes we currently still defer to Delve, for
+		// compatibility with the old debugAdapter.
+		// See https://github.com/golang/vscode-go/issues/336
 		if (args.noDebug && args.mode === 'debug') {
 			try {
 				this.launchNoDebug(args);
@@ -237,6 +237,8 @@
 		});
 
 		this.dlvClient.on('connected', () => {
+			// Once the client is connected to Delve, forward it the launch
+			// request to begin the actual debugging session.
 			this.dlvClient.send(request);
 		});
 
@@ -600,6 +602,9 @@
 	// This implements the `Run > Run Without Debugger` functionality in vscode.
 	// Note: this method currently assumes launchArgs.mode === 'debug'.
 	private launchNoDebug(launchArgs: LaunchRequestArguments): void {
+		if (launchArgs.mode !== 'debug') {
+			throw new Error('launchNoDebug requires "debug" mode');
+		}
 		const program = launchArgs.program;
 		if (!program) {
 			throw new Error('The program attribute is missing in the debug configuration in launch.json');
@@ -668,7 +673,7 @@
 //
 // After creation, it emits the following events:
 //
-//    'connected':            delve is connected to delve
+//    'connected':            client is connected to delve
 //    'request (request)':    delve sent request
 //    'response (response)':  delve sent response
 //    'event (event)':        delve sent event