parent
347e1eb352
commit
64f61e4c91
@ -268,13 +268,14 @@ local function open_in_new_window(filename, mode)
|
|||||||
local fname = vim.fn.fnameescape(filename)
|
local fname = vim.fn.fnameescape(filename)
|
||||||
fname = utils.escape_special_chars(fname)
|
fname = utils.escape_special_chars(fname)
|
||||||
|
|
||||||
local cmd
|
local command
|
||||||
if create_new_window then
|
if create_new_window then
|
||||||
cmd = string.format("%s vsplit %s", new_window_side, fname)
|
-- generated from vim.api.nvim_parse_cmd("belowright vsplit foo", {})
|
||||||
|
command = { cmd = "vsplit", mods = { split = new_window_side }, args = { fname } }
|
||||||
elseif mode:match "split$" then
|
elseif mode:match "split$" then
|
||||||
cmd = string.format("%s %s", mode, fname)
|
command = { cmd = mode, args = { fname } }
|
||||||
else
|
else
|
||||||
cmd = string.format("edit %s", fname)
|
command = { cmd = "edit", args = { fname } }
|
||||||
end
|
end
|
||||||
|
|
||||||
if (mode == "preview" or mode == "preview_no_picker") and view.View.float.enable then
|
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)
|
|||||||
set_current_win_no_autocmd(target_winid, { "BufEnter" })
|
set_current_win_no_autocmd(target_winid, { "BufEnter" })
|
||||||
end
|
end
|
||||||
|
|
||||||
pcall(vim.cmd, cmd)
|
pcall(vim.cmd, command)
|
||||||
lib.set_target_win()
|
lib.set_target_win()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -422,11 +422,21 @@ function Builder:build_header()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Sanitize lines for rendering.
|
||||||
|
---Replace newlines with literal \n
|
||||||
|
---@private
|
||||||
|
function Builder:sanitize_lines()
|
||||||
|
self.lines = vim.tbl_map(function(line)
|
||||||
|
return line and line:gsub("\n", "\\n") or ""
|
||||||
|
end, self.lines)
|
||||||
|
end
|
||||||
|
|
||||||
---Build all lines with highlights and signs
|
---Build all lines with highlights and signs
|
||||||
---@return Builder
|
---@return Builder
|
||||||
function Builder:build()
|
function Builder:build()
|
||||||
self:build_header()
|
self:build_header()
|
||||||
self:build_lines()
|
self:build_lines()
|
||||||
|
self:sanitize_lines()
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user