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
@@ -152,7 +152,7 @@ M.get_reviewer_data = function()
|
||||
return
|
||||
end
|
||||
|
||||
local current_file = M.get_current_file()
|
||||
local current_file = M.get_current_file_path()
|
||||
if current_file == nil then
|
||||
u.notify("Error getting current file from Diffview", vim.log.levels.ERROR)
|
||||
return
|
||||
@@ -163,7 +163,7 @@ M.get_reviewer_data = function()
|
||||
|
||||
local is_current_sha_focused = M.is_current_sha_focused()
|
||||
|
||||
local modification_type = hunks.get_modification_type(old_line, new_line, current_file, is_current_sha_focused)
|
||||
local modification_type = hunks.get_modification_type(old_line, new_line, is_current_sha_focused)
|
||||
if modification_type == nil then
|
||||
u.notify("Error getting modification type", vim.log.levels.ERROR)
|
||||
return
|
||||
@@ -180,6 +180,7 @@ M.get_reviewer_data = function()
|
||||
|
||||
return {
|
||||
file_name = layout.a.file.path,
|
||||
old_file_name = M.is_file_renamed() and layout.b.file.path or "",
|
||||
old_line_from_buf = old_line,
|
||||
new_line_from_buf = new_line,
|
||||
modification_type = modification_type,
|
||||
@@ -205,14 +206,38 @@ M.is_current_sha_focused = function()
|
||||
return current_win == b_win
|
||||
end
|
||||
|
||||
---Get currently shown file
|
||||
---@return string|nil
|
||||
M.get_current_file = function()
|
||||
---Get currently shown file data
|
||||
M.get_current_file_data = function()
|
||||
local view = diffview_lib.get_current_view()
|
||||
if not view or not view.panel or not view.panel.cur_file then
|
||||
return
|
||||
end
|
||||
return view.panel.cur_file.path
|
||||
return view and view.panel and view.panel.cur_file
|
||||
end
|
||||
|
||||
---Get currently shown file path
|
||||
---@return string|nil
|
||||
M.get_current_file_path = function()
|
||||
local file_data = M.get_current_file_data()
|
||||
return file_data and file_data.path
|
||||
end
|
||||
|
||||
---Get currently shown file's old path
|
||||
---@return string|nil
|
||||
M.get_current_file_oldpath = function()
|
||||
local file_data = M.get_current_file_data()
|
||||
return file_data and file_data.oldpath
|
||||
end
|
||||
|
||||
---Tell whether current file is renamed or not
|
||||
---@return boolean|nil
|
||||
M.is_file_renamed = function()
|
||||
local file_data = M.get_current_file_data()
|
||||
return file_data and file_data.status == "R"
|
||||
end
|
||||
|
||||
---Tell whether current file has changes or not
|
||||
---@return boolean|nil
|
||||
M.does_file_have_changes = function()
|
||||
local file_data = M.get_current_file_data()
|
||||
return file_data.stats.additions > 0 or file_data.stats.deletions > 0
|
||||
end
|
||||
|
||||
---Diffview exposes events which can be used to setup autocommands.
|
||||
|
||||
@@ -96,7 +96,13 @@ function Location:get_line_number_from_new_sha(line)
|
||||
return line
|
||||
end
|
||||
-- Otherwise we want to get the matching line in the opposite buffer
|
||||
return hunks.calculate_matching_line_new(self.base_sha, self.head_sha, self.reviewer_data.file_name, line)
|
||||
return hunks.calculate_matching_line_new(
|
||||
self.base_sha,
|
||||
self.head_sha,
|
||||
self.reviewer_data.file_name,
|
||||
self.reviewer_data.old_file_name,
|
||||
line
|
||||
)
|
||||
end
|
||||
|
||||
-- Returns the matching line from the old SHA.
|
||||
@@ -112,7 +118,13 @@ function Location:get_line_number_from_old_sha(line)
|
||||
end
|
||||
|
||||
-- Otherwise we want to get the matching line in the opposite buffer
|
||||
return hunks.calculate_matching_line_new(self.head_sha, self.base_sha, self.reviewer_data.file_name, line)
|
||||
return hunks.calculate_matching_line_new(
|
||||
self.head_sha,
|
||||
self.base_sha,
|
||||
self.reviewer_data.file_name,
|
||||
self.reviewer_data.old_file_name,
|
||||
line
|
||||
)
|
||||
end
|
||||
|
||||
-- Returns the current line number from whatever SHA (new or old)
|
||||
@@ -135,7 +147,7 @@ end
|
||||
---@param visual_range LineRange
|
||||
---@return ReviewerLineInfo|nil
|
||||
function Location:set_start_range(visual_range)
|
||||
local current_file = require("gitlab.reviewer").get_current_file()
|
||||
local current_file = require("gitlab.reviewer").get_current_file_path()
|
||||
if current_file == nil then
|
||||
u.notify("Error getting current file from Diffview", vim.log.levels.ERROR)
|
||||
return
|
||||
@@ -165,7 +177,7 @@ function Location:set_start_range(visual_range)
|
||||
return
|
||||
end
|
||||
|
||||
local modification_type = hunks.get_modification_type(old_line, new_line, current_file, is_current_sha_focused)
|
||||
local modification_type = hunks.get_modification_type(old_line, new_line, is_current_sha_focused)
|
||||
if modification_type == nil then
|
||||
u.notify("Error getting modification type for start of range", vim.log.levels.ERROR)
|
||||
return
|
||||
@@ -182,7 +194,7 @@ end
|
||||
-- for the Gitlab payload
|
||||
---@param visual_range LineRange
|
||||
function Location:set_end_range(visual_range)
|
||||
local current_file = require("gitlab.reviewer").get_current_file()
|
||||
local current_file = require("gitlab.reviewer").get_current_file_path()
|
||||
if current_file == nil then
|
||||
u.notify("Error getting current file from Diffview", vim.log.levels.ERROR)
|
||||
return
|
||||
@@ -207,7 +219,7 @@ function Location:set_end_range(visual_range)
|
||||
|
||||
local reviewer = require("gitlab.reviewer")
|
||||
local is_current_sha_focused = reviewer.is_current_sha_focused()
|
||||
local modification_type = hunks.get_modification_type(old_line, new_line, current_file, is_current_sha_focused)
|
||||
local modification_type = hunks.get_modification_type(old_line, new_line, is_current_sha_focused)
|
||||
if modification_type == nil then
|
||||
u.notify("Error getting modification type for end of range", vim.log.levels.ERROR)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user