Skip to content

Commit 048c44d

Browse files
authored
Merge pull request #1569 from digeff/use_external_console
Now WebKit V2 debugger will launch the Node process in an external te…
2 parents 034042f + 06a6c7d commit 048c44d

1 file changed

Lines changed: 25 additions & 15 deletions

File tree

Nodejs/Product/Nodejs/Project/NodejsProjectLauncher.cs

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,8 @@ private void StartWithChromeV2Debugger(string program, string nodeRuntimeExecuta
404404
}
405405

406406
// Here we need to massage the env variables into the format expected by node and vs code
407-
object envVars = GetEnvironmentVariables();
407+
var webBrowserUrl = GetFullUrl();
408+
var envVars = GetEnvironmentVariables(webBrowserUrl);
408409

409410
var cwd = _project.GetWorkingDirectory(); // Current working directory
410411
var configuration = new JObject(
@@ -414,7 +415,8 @@ private void StartWithChromeV2Debugger(string program, string nodeRuntimeExecuta
414415
new JProperty("program", program),
415416
new JProperty("runtimeExecutable", nodeRuntimeExecutable),
416417
new JProperty("cwd", cwd),
417-
new JProperty("env", envVars),
418+
new JProperty("console", "externalTerminal"),
419+
new JProperty("env", JObject.FromObject(envVars)),
418420
new JProperty("diagnosticLogging", CheckEnableDiagnosticLoggingOption()),
419421
new JProperty("sourceMaps", true),
420422
new JProperty("stopOnEntry", true),
@@ -440,7 +442,6 @@ private void StartWithChromeV2Debugger(string program, string nodeRuntimeExecuta
440442
// Launch browser
441443
if (startBrowser)
442444
{
443-
var webBrowserUrl = GetFullUrl();
444445
Uri uri = null;
445446
if (!String.IsNullOrWhiteSpace(webBrowserUrl))
446447
{
@@ -552,6 +553,26 @@ private bool SetupDebugInfo(ref VsDebugTargetInfo dbgInfo, string startupFile)
552553
}
553554

554555
private string GetEnvironmentVariablesString(string url)
556+
{
557+
var env = GetEnvironmentVariables(url);
558+
if (env.Count > 0)
559+
{
560+
//Environment variables should be passed as a
561+
//null-terminated block of null-terminated strings.
562+
//Each string is in the following form:name=value\0
563+
var buf = new StringBuilder();
564+
foreach (var entry in env)
565+
{
566+
buf.AppendFormat("{0}={1}\0", entry.Key, entry.Value);
567+
}
568+
buf.Append("\0");
569+
return buf.ToString();
570+
}
571+
572+
return null;
573+
}
574+
575+
private Dictionary<string, string> GetEnvironmentVariables(string url)
555576
{
556577
var env = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
557578
if (!string.IsNullOrWhiteSpace(url))
@@ -577,20 +598,9 @@ private string GetEnvironmentVariablesString(string url)
577598
env.Add(strKey, (string)variables[key]);
578599
}
579600
}
580-
581-
//Environment variables should be passed as a
582-
//null-terminated block of null-terminated strings.
583-
//Each string is in the following form:name=value\0
584-
var buf = new StringBuilder();
585-
foreach (var entry in env)
586-
{
587-
buf.AppendFormat("{0}={1}\0", entry.Key, entry.Value);
588-
}
589-
buf.Append("\0");
590-
return buf.ToString();
591601
}
592602

593-
return null;
603+
return env;
594604
}
595605

596606
private bool ShouldStartBrowser()

0 commit comments

Comments
 (0)