Skip to content

Commit

Permalink
--wip-- [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeLagrange committed Sep 30, 2024
1 parent ab4889c commit efce6f0
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions lua/octo/ui/writers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function M.write_block(bufnr, lines, line, mark)
mark = mark or false

if type(lines) == "string" then
lines = vim.split(lines, "\n", true)
lines = vim.split(lines, "\n")
end

-- write content lines
Expand Down Expand Up @@ -46,7 +46,9 @@ function M.write_block(bufnr, lines, line, mark)
end

return vim.api.nvim_buf_set_extmark(bufnr, constants.OCTO_COMMENT_NS, math.max(0, start_line - 1 - 1), 0, {
end_line = math.min(end_line + 2 - 1, vim.api.nvim_buf_line_count(bufnr)),
virt_text = { { "foo ", "Normal" } },
virt_text_pos = "inline",
end_line = end_line,
end_col = 0,
})
end
Expand Down Expand Up @@ -595,9 +597,20 @@ function M.write_comment(bufnr, comment, kind, line)
if vim.startswith(comment_body, constants.NO_BODY_MSG) or utils.is_blank(comment_body) then
comment_body = " "
end
local content = vim.split(comment_body, "\n", true)
local content = vim.split(comment_body, "\n")
vim.list_extend(content, { "" })

-- Set extmark with virtual text at the beginning of the line
local comment_mark = M.write_block(bufnr, content, line, true)
--
-- -- Define the number of spaces for indentation (e.g., 4 spaces per indent level)
-- local indent_text = string.rep(" ", 2 * 4) -- Adjust 4 based on your desired indent width
-- vim.api.nvim_buf_set_extmark(bufnr, comment_vt_ns, line - 1, 0, {
-- virt_lines = { { { "foo" .. indent_text, "Normal" } }, { { "bar" .. indent_text, "Normal" } } },
-- virt_lines_leftcol = true,
-- end_row = line + 1,
-- virt_text_pos = "inline",
-- })

line = line + #content

Expand Down

0 comments on commit efce6f0

Please sign in to comment.