Skip to content

Commit

Permalink
Fixed file path quoting determination for text file opening
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenldl committed Nov 6, 2024
1 parent 207b9f0 commit 8537dc7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions bin/docfd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,7 @@ let run
close_term ();
Misc_utils.gen_command_to_open_text_file_to_line_num
~editor:!Params.text_editor
~quote_path:true
~path:file
~line_num:(max 1 (Dynarray.length snapshots - 1))
|> Sys.command
Expand Down
9 changes: 7 additions & 2 deletions bin/misc_utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,13 @@ let normalize_filter_glob_if_not_empty (s : string) =
normalize_glob_to_absolute s
)

let gen_command_to_open_text_file_to_line_num ~editor ~path ~line_num =
let path = Filename.quote path in
let gen_command_to_open_text_file_to_line_num ~editor ~quote_path ~path ~line_num =
let path =
if quote_path then
Filename.quote path
else
path
in
let fallback = Fmt.str "%s %s" editor path in
match Filename.basename editor with
| "nano" ->
Expand Down
3 changes: 2 additions & 1 deletion bin/path_open.ml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ let pdf index ~path ~search_result =
Proc_utils.run_in_background cmd |> ignore

let text index document_src ~editor ~path ~search_result =
let path = Filename.quote path in
let fallback = Fmt.str "%s %s" editor path in
let cmd =
match search_result with
Expand All @@ -142,7 +143,7 @@ let text index document_src ~editor ~path ~search_result =
|> (fun x -> x + 1)
in
Misc_utils.gen_command_to_open_text_file_to_line_num
~editor ~path ~line_num
~editor ~quote_path:false ~path ~line_num
)
in
let cmd =
Expand Down

0 comments on commit 8537dc7

Please sign in to comment.