diff options
| author | Michiel van den Heuvel <michielvdnheuvel@gmail.com> | 2023-07-20 16:23:32 +0200 |
|---|---|---|
| committer | Michiel van den Heuvel <michielvdnheuvel@gmail.com> | 2023-08-28 12:30:19 +0200 |
| commit | 7598f649f419fa897794005c3b74d5e46852625c (patch) | |
| tree | 2b692b345d730ecb9aa5c04f43ad195978f50110 /init.lua | |
| parent | 1b0968ef3901d9b03a8c3eb4d9299c1816bd59e5 (diff) | |
| download | vis-lspc-7598f649f419fa897794005c3b74d5e46852625c.tar.gz vis-lspc-7598f649f419fa897794005c3b74d5e46852625c.zip | |
Fix filename escaping when opening a file
Diffstat (limited to 'init.lua')
| -rw-r--r-- | init.lua | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -399,6 +399,10 @@ local function lspc_confirm(prompt) return choice == 'yes' end +local function vis_open_file(file, cmd) + vis:command(('%s %s'):format(cmd, file:gsub('[\\\t "\']', '\\%1'):gsub('\n', '\\n'))) +end + -- open a doc_pos using the vis command <cmd> local function vis_open_doc_pos(doc_pos, cmd, win) if win and win ~= vis.win then @@ -414,7 +418,7 @@ local function vis_open_doc_pos(doc_pos, cmd, win) return end end - vis:command(string.format('%s \'%s\'', cmd, doc_pos.file)) + vis_open_file(doc_pos.file, cmd) vis.win.selection:to(doc_pos.line, doc_pos.col) vis:command('lspc-open') else @@ -530,7 +534,7 @@ local function vis_apply_workspaceEdit(_, _, workspaceEdit) -- It is not open currently -> open it local opened if not win_with_file then - vis:command('o ' .. path) + vis_open_file(path, 'o') win_with_file = vis.win opened = true end |
