Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lua/gitlab/actions/discussions/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ M.initialize_discussions = function()
end)
reviewer.set_callback_for_buf_read(function(args)
vim.api.nvim_set_option_value("modifiable", false, { buf = args.buf })
reviewer.update_winid_for_buffer(args.buf)
reviewer.set_keymaps(args.buf)
reviewer.set_reviewer_autocommands(args.buf)
end)
Expand Down
8 changes: 6 additions & 2 deletions lua/gitlab/reviewer/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ M.open = function()
end
end

M.is_open = true
vim.api.nvim_command(string.format("%s %s..%s", diffview_open_command, diff_refs.base_sha, diff_refs.head_sha))

M.is_open = true
M.diffview = require("diffview.lib").get_current_view()
if M.diffview == nil then
u.notify("Could not find Diffview view", vim.log.levels.ERROR)
Expand Down Expand Up @@ -304,7 +304,11 @@ M.set_callback_for_buf_read = function(callback)
pattern = { "DiffviewDiffBufRead" },
group = group,
callback = function(...)
if vim.api.nvim_get_current_tabpage() == M.tabid then
-- Only run the callback when we're in the MR's tabpage or when the tabpage has
-- not yet been set (tabid = nil) in a freshly started review (is_open = true).
-- TODO: This is a hacky workaround for cases when an added file is diffeed
-- against diffview://null and this autocommand fires before tabid is set.
if vim.api.nvim_get_current_tabpage() == M.tabid or (M.is_open and M.tabid == nil) then
callback(...)
end
end,
Expand Down
Loading