From 71a2f64940023d82ba04053aef4f01e921973877 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Tue, 24 Sep 2024 16:37:56 -0400 Subject: [PATCH] update editor_link --- stdlib/Profile/src/Profile.jl | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/stdlib/Profile/src/Profile.jl b/stdlib/Profile/src/Profile.jl index 76333523099638..279ab73cc768aa 100644 --- a/stdlib/Profile/src/Profile.jl +++ b/stdlib/Profile/src/Profile.jl @@ -807,25 +807,26 @@ end # make a terminal-clickable link to the file and linenum. # Similar to `define_default_editors` in `Base.Filesystem` but for creating URIs not commands function editor_link(path::String, linenum::Int) - editor = get(ENV, "JULIA_EDITOR", "") - path = escape_string(path) + editor = Base.editor_string() + path_encoded = Base.Filesystem.encode_uri_component(path) if editor == "code" - return "vscode://file/$path:$linenum" + return "vscode://file/$path_encoded:$linenum" elseif editor == "subl" || editor == "sublime_text" - return "subl://$path:$linenum" + return "subl://open?url=file://$path_encoded&line=$linenum" elseif editor == "idea" || occursin("idea", editor) - return "idea://open?file=$path&line=$linenum" + return "idea://open?file=$path_encoded&line=$linenum" elseif editor == "pycharm" - return "pycharm://open?file=$path&line=$linenum" + return "pycharm://open?file=$path_encoded&line=$linenum" elseif editor == "atom" - return "atom://core/open/file?filename=$path&line=$linenum" - elseif editor == "emacsclient" - return "emacs://open?file=$path&line=$linenum" + return "atom://core/open/file?filename=$path_encoded&line=$linenum" + elseif editor == "emacsclient" || editor == "emacs" + return "emacs://open?file=$path_encoded&line=$linenum" elseif editor == "vim" || editor == "nvim" - return "vim://open?file=$path&line=$linenum" + # Note: Vim/Nvim may not support standard URI schemes without specific plugins + return "vim://open?file=$path_encoded&line=$linenum" else - # TODO: convert the path to a generic URI (line numbers are not supported by generic URI) - return path + # line numbers are not supported by generic URI + return Base.Filesystem.uripath(path) end end