File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ local diffview_lib = require("diffview.lib")
99local M = {
1010 bufnr = nil ,
1111 tabnr = nil ,
12+ stored_win = nil ,
1213}
1314
1415-- Checks for legacy installations, only Diffview is supported.
@@ -199,7 +200,14 @@ M.is_current_sha = function()
199200 local view = diffview_lib .get_current_view ()
200201 local layout = view .cur_layout
201202 local b_win = u .get_window_id_by_buffer_id (layout .b .file .bufnr )
203+ local a_win = u .get_window_id_by_buffer_id (layout .a .file .bufnr )
202204 local current_win = vim .fn .win_getid ()
205+
206+ -- Handle cases where user navigates tabs in the middle of making a comment
207+ if a_win ~= current_win and b_win ~= current_win then
208+ current_win = M .stored_win
209+ M .stored_win = nil
210+ end
203211 return current_win == b_win
204212end
205213
@@ -266,6 +274,7 @@ M.set_callback_for_file_changed = function(callback)
266274 pattern = { " DiffviewDiffBufWinEnter" },
267275 group = group ,
268276 callback = function (...)
277+ M .stored_win = vim .api .nvim_get_current_win ()
269278 if M .tabnr == vim .api .nvim_get_current_tabpage () then
270279 callback (... )
271280 end
You can’t perform that action at this time.
0 commit comments