Miscellaneous Bug Fixes (#423)
fix: Show non-resolvable notes in winbar (#417) fix: add more emojis and make emoji picker configurable (#414) fix: comment creation should not be possible for renamed and moved files (#416) fix: color highlight groups are invalid (#421) fix: plugin failing to build on Windows (#419) --------- Co-authored-by: Jakub F. Bortlík <jakub.bortlik@proton.me>
This commit is contained in:
committed by
GitHub
parent
30daecfb60
commit
be027331e1
@@ -80,6 +80,7 @@ local confirm_create_comment = function(text, visual_range, unlinked, discussion
|
||||
local revision = state.MR_REVISIONS[1]
|
||||
local position_data = {
|
||||
file_name = reviewer_data.file_name,
|
||||
old_file_name = reviewer_data.old_file_name,
|
||||
base_commit_sha = revision.base_commit_sha,
|
||||
start_commit_sha = revision.start_commit_sha,
|
||||
head_commit_sha = revision.head_commit_sha,
|
||||
@@ -179,6 +180,12 @@ M.create_comment_layout = function(opts)
|
||||
return
|
||||
end
|
||||
|
||||
-- Check that the file has not been renamed
|
||||
if reviewer.is_file_renamed() and not reviewer.does_file_have_changes() then
|
||||
u.notify("Commenting on (unchanged) renamed or moved files is not supported", vim.log.levels.WARN)
|
||||
return
|
||||
end
|
||||
|
||||
-- Check that we are hovering over the code
|
||||
local filetype = vim.bo[0].filetype
|
||||
if not opts.reply and (filetype == "DiffviewFiles" or filetype == "gitlab") then
|
||||
@@ -249,7 +256,6 @@ end
|
||||
--- This function will open a comment popup in order to create a comment on the changed/updated
|
||||
--- line in the current MR
|
||||
M.create_comment = function()
|
||||
vim.print("Creating comment...")
|
||||
local has_clean_tree, err = git.has_clean_tree()
|
||||
if err ~= nil then
|
||||
return
|
||||
@@ -293,7 +299,6 @@ end
|
||||
--- This function will open a a popup to create a "note" (e.g. unlinked comment)
|
||||
--- on the changed/updated line in the current MR
|
||||
M.create_note = function()
|
||||
vim.print("Creating note...")
|
||||
local layout = M.create_comment_layout({ ranged = false, unlinked = true })
|
||||
if layout ~= nil then
|
||||
layout:mount()
|
||||
@@ -354,6 +359,8 @@ M.create_comment_suggestion = function()
|
||||
local layout = M.create_comment_layout({ ranged = range_length > 0, unlinked = false })
|
||||
if layout ~= nil then
|
||||
layout:mount()
|
||||
else
|
||||
return -- Failure in creating the comment layout
|
||||
end
|
||||
vim.schedule(function()
|
||||
if suggestion_lines then
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
local u = require("gitlab.utils")
|
||||
local List = require("gitlab.utils.list")
|
||||
local state = require("gitlab.state")
|
||||
|
||||
@@ -17,12 +18,13 @@ M.set_buffers = function(linked_bufnr, unlinked_bufnr)
|
||||
end
|
||||
|
||||
---@param nodes Discussion[]|UnlinkedDiscussion[]|nil
|
||||
---@return number, number
|
||||
---@return number, number, number
|
||||
local get_data = function(nodes)
|
||||
local total_resolvable = 0
|
||||
local total_resolved = 0
|
||||
local total_non_resolvable = 0
|
||||
if nodes == nil or nodes == vim.NIL then
|
||||
return total_resolvable, total_resolved
|
||||
return total_resolvable, total_resolved, total_non_resolvable
|
||||
end
|
||||
|
||||
total_resolvable = List.new(nodes):reduce(function(agg, d)
|
||||
@@ -33,6 +35,14 @@ local get_data = function(nodes)
|
||||
return agg
|
||||
end, 0)
|
||||
|
||||
total_non_resolvable = List.new(nodes):reduce(function(agg, d)
|
||||
local first_child = d.notes[1]
|
||||
if first_child and not first_child.resolvable then
|
||||
agg = agg + 1
|
||||
end
|
||||
return agg
|
||||
end, 0)
|
||||
|
||||
total_resolved = List.new(nodes):reduce(function(agg, d)
|
||||
local first_child = d.notes[1]
|
||||
if first_child and first_child.resolved then
|
||||
@@ -41,12 +51,13 @@ local get_data = function(nodes)
|
||||
return agg
|
||||
end, 0)
|
||||
|
||||
return total_resolvable, total_resolved
|
||||
return total_resolvable, total_resolved, total_non_resolvable
|
||||
end
|
||||
|
||||
local function content()
|
||||
local resolvable_discussions, resolved_discussions = get_data(state.DISCUSSION_DATA.discussions)
|
||||
local resolvable_notes, resolved_notes = get_data(state.DISCUSSION_DATA.unlinked_discussions)
|
||||
local resolvable_discussions, resolved_discussions, non_resolvable_discussions =
|
||||
get_data(state.DISCUSSION_DATA.discussions)
|
||||
local resolvable_notes, resolved_notes, non_resolvable_notes = get_data(state.DISCUSSION_DATA.unlinked_discussions)
|
||||
|
||||
local draft_notes = require("gitlab.actions.draft_notes")
|
||||
local inline_draft_notes, unlinked_draft_notes = List.new(state.DRAFT_NOTES):partition(function(note)
|
||||
@@ -64,10 +75,12 @@ local function content()
|
||||
local t = {
|
||||
resolvable_discussions = resolvable_discussions,
|
||||
resolved_discussions = resolved_discussions,
|
||||
non_resolvable_discussions = non_resolvable_discussions,
|
||||
inline_draft_notes = #inline_draft_notes,
|
||||
unlinked_draft_notes = #unlinked_draft_notes,
|
||||
resolvable_notes = resolvable_notes,
|
||||
resolved_notes = resolved_notes,
|
||||
non_resolvable_notes = non_resolvable_notes,
|
||||
help_keymap = state.settings.keymaps.help,
|
||||
}
|
||||
|
||||
@@ -94,34 +107,58 @@ M.update_winbar = function()
|
||||
vim.api.nvim_set_option_value("winbar", c, { scope = "local", win = win_id })
|
||||
end
|
||||
|
||||
local function get_connector(base_title)
|
||||
return string.match(base_title, "%($") and "" or "; "
|
||||
end
|
||||
|
||||
---Builds the title string for both sections, using the count of resolvable and draft nodes
|
||||
---@param base_title string
|
||||
---@param resolvable_count integer
|
||||
---@param resolved_count integer
|
||||
---@param drafts_count integer
|
||||
---@return string
|
||||
local add_drafts_and_resolvable = function(base_title, resolvable_count, resolved_count, drafts_count)
|
||||
local add_drafts_and_resolvable = function(
|
||||
base_title,
|
||||
resolvable_count,
|
||||
resolved_count,
|
||||
drafts_count,
|
||||
non_resolvable_count
|
||||
)
|
||||
if resolvable_count == 0 and drafts_count == 0 and non_resolvable_count == 0 then
|
||||
return base_title
|
||||
end
|
||||
base_title = base_title .. " ("
|
||||
if non_resolvable_count ~= 0 then
|
||||
base_title = base_title .. u.pluralize(non_resolvable_count, "comment")
|
||||
end
|
||||
if resolvable_count ~= 0 then
|
||||
base_title = base_title .. string.format(" (%d/%d resolved", resolvable_count, resolved_count)
|
||||
base_title = base_title
|
||||
.. get_connector(base_title)
|
||||
.. string.format("%d/%s", resolved_count, u.pluralize(resolvable_count, "thread"))
|
||||
end
|
||||
if drafts_count ~= 0 then
|
||||
if resolvable_count ~= 0 then
|
||||
base_title = base_title .. string.format("; %d drafts)", drafts_count)
|
||||
else
|
||||
base_title = base_title .. string.format(" (%d drafts)", drafts_count)
|
||||
end
|
||||
elseif resolvable_count ~= 0 then
|
||||
base_title = base_title .. ")"
|
||||
base_title = base_title .. get_connector(base_title) .. u.pluralize(drafts_count, "draft")
|
||||
end
|
||||
|
||||
base_title = base_title .. ")"
|
||||
return base_title
|
||||
end
|
||||
|
||||
---@param t WinbarTable
|
||||
M.make_winbar = function(t)
|
||||
local discussion_title =
|
||||
add_drafts_and_resolvable("Inline Comments", t.resolvable_discussions, t.resolved_discussions, t.inline_draft_notes)
|
||||
local notes_title = add_drafts_and_resolvable("Notes", t.resolvable_notes, t.resolved_notes, t.unlinked_draft_notes)
|
||||
local discussion_title = add_drafts_and_resolvable(
|
||||
"Inline Comments",
|
||||
t.resolvable_discussions,
|
||||
t.resolved_discussions,
|
||||
t.inline_draft_notes,
|
||||
t.non_resolvable_discussions
|
||||
)
|
||||
local notes_title = add_drafts_and_resolvable(
|
||||
"Notes",
|
||||
t.resolvable_notes,
|
||||
t.resolved_notes,
|
||||
t.unlinked_draft_notes,
|
||||
t.non_resolvable_notes
|
||||
)
|
||||
|
||||
-- Colorize the active tab
|
||||
if M.current_view_type == "discussions" then
|
||||
|
||||
Reference in New Issue
Block a user