Skip to content

Commit

Permalink
update editor_link
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Sep 24, 2024
1 parent c2bfcda commit 71a2f64
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions stdlib/Profile/src/Profile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 71a2f64

Please sign in to comment.