Skip to content

Commit 7f82f19

Browse files
committed
fix(fzf): sanitize preview content to avoid newline issues in fzf-lua
1 parent 4714d05 commit 7f82f19

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

lua/tiny-code-action/previewers/fzf-lua.lua

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,20 @@ local function preview_buf(opts)
6363
function CodeActionPreviewerBuf:populate_preview_buf(entry_str)
6464
local preview_content = extract_preview_data(entry_str, opts)
6565

66+
local sanitized_preview = {}
67+
68+
for _, line in ipairs(preview_content) do
69+
if type(line) == "string" and line:find("\n") then
70+
local split_lines = vim.split(line, "\n", { plain = true })
71+
vim.list_extend(sanitized_preview, split_lines)
72+
else
73+
table.insert(sanitized_preview, line)
74+
end
75+
end
76+
6677
local temp_buf = self:get_tmp_buffer()
67-
vim.api.nvim_buf_set_lines(temp_buf, 0, -1, false, preview_content)
78+
79+
vim.api.nvim_buf_set_lines(temp_buf, 0, -1, false, sanitized_preview)
6880
utils.set_buf_option(temp_buf, "filetype", "diff")
6981

7082
self:set_preview_buf(temp_buf)

0 commit comments

Comments
 (0)