Skip to content

Commit 8a9d8ba

Browse files
--wip-- [skip ci]
1 parent ab4889c commit 8a9d8ba

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

lua/octo/ui/writers.lua

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function M.write_block(bufnr, lines, line, mark)
1717
mark = mark or false
1818

1919
if type(lines) == "string" then
20-
lines = vim.split(lines, "\n", true)
20+
lines = vim.split(lines, "\n")
2121
end
2222

2323
-- write content lines
@@ -45,6 +45,16 @@ function M.write_block(bufnr, lines, line, mark)
4545
end
4646
end
4747

48+
local indent_text = string.rep(" ", 2 * 4)
49+
for i = start_line, end_line do
50+
vim.api.nvim_buf_set_extmark(bufnr, constants.OCTO_COMMENT_NS, i - 1, 0, {
51+
virt_text = { { indent_text, "Whitespace" } },
52+
virt_text_pos = "inline",
53+
virt_text_repeat_linebreak = true,
54+
right_gravity = false,
55+
})
56+
end
57+
4858
return vim.api.nvim_buf_set_extmark(bufnr, constants.OCTO_COMMENT_NS, math.max(0, start_line - 1 - 1), 0, {
4959
end_line = math.min(end_line + 2 - 1, vim.api.nvim_buf_line_count(bufnr)),
5060
end_col = 0,
@@ -595,9 +605,20 @@ function M.write_comment(bufnr, comment, kind, line)
595605
if vim.startswith(comment_body, constants.NO_BODY_MSG) or utils.is_blank(comment_body) then
596606
comment_body = " "
597607
end
598-
local content = vim.split(comment_body, "\n", true)
608+
local content = vim.split(comment_body, "\n")
599609
vim.list_extend(content, { "" })
610+
611+
-- Set extmark with virtual text at the beginning of the line
600612
local comment_mark = M.write_block(bufnr, content, line, true)
613+
--
614+
-- -- Define the number of spaces for indentation (e.g., 4 spaces per indent level)
615+
-- local indent_text = string.rep(" ", 2 * 4) -- Adjust 4 based on your desired indent width
616+
-- vim.api.nvim_buf_set_extmark(bufnr, comment_vt_ns, line - 1, 0, {
617+
-- virt_lines = { { { "foo" .. indent_text, "Normal" } }, { { "bar" .. indent_text, "Normal" } } },
618+
-- virt_lines_leftcol = true,
619+
-- end_row = line + 1,
620+
-- virt_text_pos = "inline",
621+
-- })
601622

602623
line = line + #content
603624

0 commit comments

Comments
 (0)