File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -268,13 +268,14 @@ local function open_in_new_window(filename, mode)
268268 local fname = vim .fn .fnameescape (filename )
269269 fname = utils .escape_special_chars (fname )
270270
271- local cmd
271+ local command
272272 if create_new_window then
273- cmd = string.format (" %s vsplit %s" , new_window_side , fname )
273+ -- generated from vim.api.nvim_parse_cmd("belowright vsplit foo", {})
274+ command = { cmd = " vsplit" , mods = { split = new_window_side }, args = { fname } }
274275 elseif mode :match " split$" then
275- cmd = string.format ( " %s %s " , mode , fname )
276+ command = { cmd = mode , args = { fname } }
276277 else
277- cmd = string.format ( " edit %s " , fname )
278+ command = { cmd = " edit" , args = { fname } }
278279 end
279280
280281 if (mode == " preview" or mode == " preview_no_picker" ) and view .View .float .enable then
@@ -286,7 +287,7 @@ local function open_in_new_window(filename, mode)
286287 set_current_win_no_autocmd (target_winid , { " BufEnter" })
287288 end
288289
289- pcall (vim .cmd , cmd )
290+ pcall (vim .cmd , command )
290291 lib .set_target_win ()
291292end
292293
Original file line number Diff line number Diff line change @@ -422,11 +422,21 @@ function Builder:build_header()
422422 end
423423end
424424
425+ --- Sanitize lines for rendering.
426+ --- Replace newlines with literal \n
427+ --- @private
428+ function Builder :sanitize_lines ()
429+ self .lines = vim .tbl_map (function (line )
430+ return line and line :gsub (" \n " , " \\ n" ) or " "
431+ end , self .lines )
432+ end
433+
425434--- Build all lines with highlights and signs
426435--- @return Builder
427436function Builder :build ()
428437 self :build_header ()
429438 self :build_lines ()
439+ self :sanitize_lines ()
430440 return self
431441end
432442
You can’t perform that action at this time.
0 commit comments