dandavison / open-in-editor

Open a local file from a URL at a line number in an editor/IDE
55 stars 8 forks source link

Add more specific tests for which editor is in env var #19

Closed eugenesvk closed 1 year ago

eugenesvk commented 1 year ago

Avoids greedily-matching for a presence of a letter o in a /opt/local/bin/vim because there is this nice editor named O The old checks remain, just have less of a priority

dandavison commented 1 year ago

I just hit a real problematic example from my own system -- could you ensure this works?

/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code
eugenesvk commented 1 year ago

by the way, why are we stripping the arguments? for example, if some user specified his var to be subl -w

-w or --wait: Wait for the files to be closed before returning

shouldn't we respect that instead of just stripping it away?

dandavison commented 1 year ago

shouldn't we respect that instead of just stripping it away?

I think I'm going to say "no" there. People use the EDITOR env var to control behavior of their editor when invoked from a shell process. The role of OpenInEditor is different - it's to open a GUI editor when clicking on a link in a terminal. So what we're doing is simply trying to infer the correct application to open; not trying to preserve behavior designed for the command-line environment.

I'm not sure how opening a link in a terminal-based editor would/should work. The shell prompt may not be available -- the link may be displayed by a pager process which is still running -- and so even if we're opening in a terminal-based editor, we'd have to spawn a new terminal window or something to do so.

dandavison commented 1 year ago

Thanks, this is much better.