diff --git a/lua/octo/reviews.lua b/lua/octo/reviews.lua index 415654dd..6fb20e15 100644 --- a/lua/octo/reviews.lua +++ b/lua/octo/reviews.lua @@ -107,7 +107,7 @@ function M.diff_changes_qf_entry(target) local repo = qf.context.pull_request_repo local number = qf.context.pull_request_number - -- calculate valid ranges + -- calculate valid comment ranges local valid_left_ranges = {} local valid_right_ranges = {} local valid_hunks = {} @@ -141,7 +141,7 @@ function M.diff_changes_qf_entry(target) bufname = left_bufname, content_bufnr = left_bufnr, hunks = valid_hunks, - ranges = valid_left_ranges, + comment_ranges = valid_left_ranges, alt_win = right_win }) @@ -172,7 +172,7 @@ function M.diff_changes_qf_entry(target) bufname = right_bufname, content_bufnr = right_bufnr, hunks = valid_hunks, - ranges = valid_right_ranges, + comment_ranges = valid_right_ranges, alt_win = left_win }) @@ -251,9 +251,9 @@ function M.add_review_comment(isSuggestion) local bufnr = api.nvim_get_current_buf() local status, props = pcall(api.nvim_buf_get_var, bufnr, "OctoDiffProps") if status and props then - -- check we are in a valid range + -- check we are in a valid comment range local diff_hunk - for i, range in ipairs(props.ranges) do + for i, range in ipairs(props.comment_ranges) do if range[1] <= line1 and range[2] >= line2 then diff_hunk = props.hunks[i] break @@ -1099,7 +1099,6 @@ function M.show_comment() if not status or not props then return end - local comments = vim.tbl_values(_review_comments) local cursor = api.nvim_win_get_cursor(0) for _, comment in ipairs(comments) do @@ -1114,6 +1113,11 @@ function M.place_comment_signs() signs.unplace(bufnr) local status, props = pcall(api.nvim_buf_get_var, bufnr, "OctoDiffProps") if status and props then + for _, range in ipairs(props.comment_ranges) do + for line = range[1], range[2] do + signs.place("octo_comment_range", bufnr, line - 1) + end + end local comments = vim.tbl_values(_review_comments) for _, comment in ipairs(comments) do if M.is_comment_placed_in_buffer(comment, bufnr) then diff --git a/lua/octo/window.lua b/lua/octo/window.lua index bf3d61d1..85b28bef 100644 --- a/lua/octo/window.lua +++ b/lua/octo/window.lua @@ -136,7 +136,7 @@ function M.create_comment_popup(win, comment) local border_width = 1 local padding = 1 local body = vim.list_extend(header, vim.split(comment.body, "\n")) - local height = math.min(2*border_width + strlen(body), vim.fn.winheight(win)) + local height = math.min(2*border_width + #body, vim.fn.winheight(win)) local preview_bufnr = api.nvim_create_buf(false, true) api.nvim_buf_set_lines(preview_bufnr, 0, -1, false, body) diff --git a/plugin/octo.vim b/plugin/octo.vim index 64b0305b..fba40805 100644 --- a/plugin/octo.vim +++ b/plugin/octo.vim @@ -61,7 +61,8 @@ au CursorHold octo://* lua require'octo'.on_cursor_hold() augroup END " sign definitions -sign define octo_comment text=❯ texthl=OctoNvimCommentLine linehl=OctoNvimCommentLine +sign define octo_comment text=❯ texthl=OctoNvimCommentSign linehl=OctoNvimCommentLine +sign define octo_comment_range text=│ texthl=OctoNvimCommentRangeLine sign define octo_clean_block_start text=┌ linehl=OctoNvimEditable sign define octo_clean_block_end text=└ linehl=OctoNvimEditable sign define octo_dirty_block_start text=┌ texthl=OctoNvimDirty linehl=OctoNvimEditable @@ -94,6 +95,8 @@ highlight default link OctoNvimDetailsLabel Title highlight default link OctoNvimDetailsValue Identifier highlight default link OctoNvimMissingDetails Comment highlight default link OctoNvimCommentLine Visual +highlight default link OctoNvimCommentSign OctoNvimYellow +highlight default link OctoNvimCommentRangeLine OctoNvimYellow highlight default link OctoNvimEditable NormalFloat highlight default link OctoNvimBubble NormalFloat highlight default link OctoNvimUser OctoNvimBubble