Bugfixes, Etc. (#502)
* Fix: Jumping to renamed files (#484) * fix: prevent "cursor position outside buffer" error * fix: swap file_name and old_file_name in reviewer data `old_file_name` is not set to the empty string for un-renamed files anymore, because then we can remove the empty-line check in `comment_helpers.go` which was used to replace the empty string with the current file name anyway. * fix: add old_file_name to discussion root node data * fix: also consider old_file_name when jumping to the reviewer This fixes jumping to renamed files, however, may not work for comments that were created on renamed files with the previous version of `gitlab.nvim` as that version assigned the `file_name` and `old_file_name` incorrectly. * refactor: don't shadow variable * fix: check file_name or old_file_name based on which SHA comment belongs to * Fix: Store reviewer data before creating comment popup (#476) * Fix: Make publishing drafts more robust (#483) * Fix: Swap file_name and old_file_name in reviewer data (#485) * Feat: Enable toggling date format between relative and absolute (#491) * Fix: Add opts to help popup (#492) * Fix: Force start_line for jumping to diagnostic to be inside buffer (#494) * fix: redefine colors after reloading colorscheme (#500) * Fix: Use path instead of oldpath as fallback for unrenamed files (#496) * Fix: Use file_name when old_file_name is not set (#495) * fix(ci): fix lua tests (#501) * Proxy Support (#499) This is a #MINOR release. --------- Co-authored-by: Jakub F. Bortlík <jakub.bortlik@proton.me> Co-authored-by: Jonathan Duck <Duckbrain30@gmail.com>
This commit is contained in:
committed by
GitHub
parent
a260f648fe
commit
e29909cd10
@@ -15,7 +15,9 @@ M.build_note_header = function(note)
|
||||
if note.note then
|
||||
return "@" .. state.USER.username .. " " .. state.settings.discussion_tree.draft
|
||||
end
|
||||
return "@" .. note.author.username .. " " .. u.time_since(note.created_at)
|
||||
local time = state.settings.discussion_tree.relative_date and u.time_since(note.created_at)
|
||||
or u.format_to_local(note.created_at, vim.fn.strftime("%z"))
|
||||
return "@" .. note.author.username .. " " .. time
|
||||
end
|
||||
|
||||
M.switch_can_edit_bufs = function(bool, ...)
|
||||
@@ -240,7 +242,9 @@ M.get_line_numbers_for_range = function(old_line, new_line, start_line_code, end
|
||||
return (old_line - range), old_line, false
|
||||
elseif new_line ~= nil then
|
||||
local range = new_end_line - new_start_line
|
||||
return (new_line - range), new_line, true
|
||||
-- Force start_line to be greater than 0
|
||||
local start_line = (new_line - range > 0) and (new_line - range) or 1
|
||||
return start_line, new_line, true
|
||||
else
|
||||
u.notify("Error getting new or old line for range", vim.log.levels.ERROR)
|
||||
return 1, 1, false
|
||||
|
||||
@@ -649,6 +649,16 @@ M.set_tree_keymaps = function(tree, bufnr, unlinked)
|
||||
})
|
||||
end
|
||||
|
||||
if keymaps.discussion_tree.toggle_date_format then
|
||||
vim.keymap.set("n", keymaps.discussion_tree.toggle_date_format, function()
|
||||
M.toggle_date_format()
|
||||
end, {
|
||||
buffer = bufnr,
|
||||
desc = "Toggle date format",
|
||||
nowait = keymaps.discussion_tree.toggle_date_format_nowait,
|
||||
})
|
||||
end
|
||||
|
||||
if keymaps.discussion_tree.toggle_resolved then
|
||||
vim.keymap.set("n", keymaps.discussion_tree.toggle_resolved, function()
|
||||
if M.is_current_node_note(tree) and not M.is_draft_note(tree) then
|
||||
@@ -725,7 +735,7 @@ M.set_tree_keymaps = function(tree, bufnr, unlinked)
|
||||
|
||||
if keymaps.help then
|
||||
vim.keymap.set("n", keymaps.help, function()
|
||||
help.open()
|
||||
help.open({ discussion_tree = true })
|
||||
end, { buffer = bufnr, desc = "Open help popup", nowait = keymaps.help_nowait })
|
||||
end
|
||||
|
||||
@@ -809,6 +819,13 @@ M.toggle_sort_method = function()
|
||||
M.rebuild_view(false, true)
|
||||
end
|
||||
|
||||
---Toggle between displaying relative time (e.g., "5 days ago") and absolute time (e.g., "04/10/2025 at 22:49")
|
||||
M.toggle_date_format = function()
|
||||
state.settings.discussion_tree.relative_date = not state.settings.discussion_tree.relative_date
|
||||
M.rebuild_unlinked_discussion_tree()
|
||||
M.rebuild_discussion_tree()
|
||||
end
|
||||
|
||||
---Indicates whether the node under the cursor is a draft note or not
|
||||
---@param tree NuiTree
|
||||
---@return boolean
|
||||
|
||||
@@ -155,6 +155,7 @@ M.build_root_draft_note = function(note)
|
||||
id = note.id,
|
||||
root_note_id = note.id,
|
||||
file_name = (type(note.position) == "table" and note.position.new_path or nil),
|
||||
old_file_name = (type(note.position) == "table" and note.position.old_path or nil),
|
||||
new_line = (type(note.position) == "table" and note.position.new_line or nil),
|
||||
old_line = (type(note.position) == "table" and note.position.old_line or nil),
|
||||
resolvable = false,
|
||||
|
||||
@@ -6,7 +6,12 @@ local state = require("gitlab.state")
|
||||
local List = require("gitlab.utils.list")
|
||||
local Popup = require("nui.popup")
|
||||
|
||||
M.open = function()
|
||||
---@class HelpPopupOpts
|
||||
---@field discussion_tree boolean|nil Whether help popup is for the discussion tree
|
||||
|
||||
--- @param opts HelpPopupOpts|nil Table with options for the help popup
|
||||
M.open = function(opts)
|
||||
local help_opts = opts or {}
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local keymaps = vim.api.nvim_buf_get_keymap(bufnr, "n")
|
||||
local help_content_lines = List.new(keymaps):reduce(function(agg, keymap)
|
||||
@@ -17,26 +22,28 @@ M.open = function()
|
||||
return agg
|
||||
end, {})
|
||||
|
||||
table.insert(help_content_lines, "")
|
||||
table.insert(
|
||||
help_content_lines,
|
||||
string.format(
|
||||
"%s = draft; %s = unlinked comment; %s = resolved",
|
||||
state.settings.discussion_tree.draft,
|
||||
state.settings.discussion_tree.unlinked,
|
||||
state.settings.discussion_tree.resolved
|
||||
if help_opts.discussion_tree then
|
||||
table.insert(help_content_lines, "")
|
||||
table.insert(
|
||||
help_content_lines,
|
||||
string.format(
|
||||
"%s = draft; %s = unlinked comment; %s = resolved",
|
||||
state.settings.discussion_tree.draft,
|
||||
state.settings.discussion_tree.unlinked,
|
||||
state.settings.discussion_tree.resolved
|
||||
)
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
local longest_line = u.get_longest_string(help_content_lines)
|
||||
local opts = { "Help", state.settings.popup.help, longest_line + 3, #help_content_lines, 70 }
|
||||
local help_popup = Popup(popup.create_popup_state(unpack(opts)))
|
||||
local popup_opts = { "Help", state.settings.popup.help, longest_line + 3, #help_content_lines, 70 }
|
||||
local help_popup = Popup(popup.create_popup_state(unpack(popup_opts)))
|
||||
|
||||
help_popup:on(event.BufLeave, function()
|
||||
help_popup:unmount()
|
||||
end)
|
||||
|
||||
popup.set_up_autocommands(help_popup, nil, vim.api.nvim_get_current_win(), opts)
|
||||
popup.set_up_autocommands(help_popup, nil, vim.api.nvim_get_current_win(), popup_opts)
|
||||
|
||||
help_popup:mount()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user