File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
app/src/main/java/io/xpipe/app/prefs Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 11package io .xpipe .app .prefs ;
22
33import io .xpipe .app .ext .PrefsChoiceValue ;
4+ import io .xpipe .app .issue .ErrorEvent ;
45import io .xpipe .app .util .ApplicationHelper ;
56import io .xpipe .app .util .WindowsRegistry ;
7+ import io .xpipe .core .impl .LocalStore ;
68import io .xpipe .core .process .OsType ;
9+ import io .xpipe .core .process .ShellDialects ;
710
811import java .io .IOException ;
912import java .nio .file .Path ;
@@ -30,6 +33,22 @@ public boolean canOpenDirectory() {
3033
3134 @ Override
3235 protected Optional <Path > determinePath () {
36+ // Try to locate if it is in the Path
37+ try (var cc = LocalStore .getShell ()
38+ .command (ShellDialects .getPlatformDefault ().getWhichCommand ("code.cmd" ))
39+ .start ()) {
40+ var out = cc .readStdoutDiscardErr ();
41+ var exit = cc .getExitCode ();
42+ if (exit == 0 ) {
43+ var first = out .lines ().findFirst ();
44+ if (first .isPresent ()) {
45+ return first .map (Path ::of );
46+ }
47+ }
48+ } catch (Exception ex ) {
49+ ErrorEvent .fromThrowable (ex ).omit ().handle ();
50+ }
51+
3352 return Optional .of (Path .of (System .getenv ("LOCALAPPDATA" ))
3453 .resolve ("Programs" )
3554 .resolve ("Microsoft VS Code" )
You can’t perform that action at this time.
0 commit comments