Make '/agent config' to use the default editor for the setting file based on its extension, like what Windows Terminal does with the "Open JSON file" button in the settings page.
This is supposed to be easy, by simply start a process with the file's path using ShellExecute. However, I run into 2 issues with that:
To simply use UseShellExecute to open a file, the file needs to exist already.
When simply using shell execute to open a file whose default editor is VSCode from a console app, VSCode writes log messages to the cosnole output and there is no way to suppress it (see screenshot below).
To resolve those 2 problems, I need to find the executable of the default application for a given file extension.
For (1), since I have the executable path of the default application, I can start it with a non-existing file and let it handle creating the file.
For (2), check if the executable points to Microsoft VS Code\Code.exe. If so, change the executable path to Microsoft VS Code\bin\code.cmd instead and start VSCode with cmd /c <path-to-code-cmd> <path-to-setting-file>.
PR Summary
Fix #163
Make '/agent config' to use the default editor for the setting file based on its extension, like what Windows Terminal does with the "Open JSON file" button in the settings page.
This is supposed to be easy, by simply start a process with the file's path using
ShellExecute
. However, I run into 2 issues with that:UseShellExecute
to open a file, the file needs to exist already.VSCode
from a console app,VSCode
writes log messages to the cosnole output and there is no way to suppress it (see screenshot below).To resolve those 2 problems, I need to find the executable of the default application for a given file extension.
Microsoft VS Code\Code.exe
. If so, change the executable path toMicrosoft VS Code\bin\code.cmd
instead and startVSCode
withcmd /c <path-to-code-cmd> <path-to-setting-file>
.