EditInVsCodeDelphiPlugin icon indicating copy to clipboard operation
EditInVsCodeDelphiPlugin copied to clipboard

Command line args for VSCode

Open thbeu opened this issue 4 months ago • 2 comments

The command line args did not work on my setup (code.exe not on PATH, reuse-window option). Here's my modification:

--- a/DGVisualStudioCodeIntegration.pas
+++ b/DGVisualStudioCodeIntegration.pas
@@ -130,12 +131,11 @@ begin
   if not SaveAllModules then
     exit;
 
-  var cmdline:string;
-  if sourceInfos.Line < 0 then
-    cmdline := Format('cmd /c "code --reuse-window %s"', [ProjectPath])
-  else
-    cmdline := Format('cmd /c "code --reuse-window %s -g %s:%d:%d"', [ProjectPath, FileName, sourceInfos.Line, sourceInfos.Column]);
-
+  var cmdline: string;
+  if sourceInfos.Line < 0 then
+    cmdline := Format('"%s" -r "%s"', ['C:\Program Files\Microsoft VS Code\Code.exe', FileName])
+  else
+    cmdline := Format('"%s" -r -g "%s":%d:%d', ['C:\Program Files\Microsoft VS Code\Code.exe', FileName, sourceInfos.Line, sourceInfos.Column]);
 
   var executor := TOSCommandLineExecutor.Create(nil);
   try

thbeu avatar Sep 05 '25 05:09 thbeu

Well, this is odd, because on my pc the "code" command not only is not located in the "program files" folder, but it is not even an exe file:

C:\Users\Carlo>where code C:\Users\Carlo\AppData\Local\Programs\Microsoft VS Code\bin\code C:\Users\Carlo\AppData\Local\Programs\Microsoft VS Code\bin\code.cmd

it is a shell script

I did install visual studio code by using the microsoft store.

csm101 avatar Sep 05 '25 13:09 csm101

There also is the option to install VSCode (Code.exe) in the user-specific folder. Might be an idea to have the file path configurable in asettings dialog instead of hard-coded.

thbeu avatar Sep 05 '25 17:09 thbeu