Skip to content

Commit d7d98ea

Browse files
txemaoteroCKolkey
authored andcommitted
Fix: jump to hunk location from status view not working
- Fix a bug introduced in PR #1862. - hunk.disk_from was used before that PR to calculate row to jump. After that, hunk.index_from was used. This commit recovers the previous behavior.
1 parent bf4e4bd commit d7d98ea

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

lua/neogit/buffers/status/actions.lua

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,8 @@ local function translate_cursor_location(self, item)
6262
for _, hunk in ipairs(item.diff.hunks) do
6363
if line >= hunk.first and line <= hunk.last then
6464
local offset = line - hunk.first
65-
local location = jump.translate_hunk_location(hunk, offset)
66-
if location then
67-
return { location.new, 0 }
68-
end
65+
local row = jump.adjust_row(hunk.disk_from, offset, hunk.lines, "-")
66+
return { row, 0 }
6967
end
7068
end
7169
end

lua/neogit/lib/jump.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ local M = {}
1414
---@param lines string[]
1515
---@param adjust_on string
1616
---@return integer
17-
local function adjust_row(start_line, offset, lines, adjust_on)
17+
function M.adjust_row(start_line, offset, lines, adjust_on)
1818
local row = start_line + offset - 1
1919

2020
for i = 1, offset do
@@ -39,8 +39,8 @@ function M.translate_hunk_location(hunk, offset)
3939
end
4040

4141
return {
42-
old = adjust_row(hunk.disk_from, offset, hunk.lines, "+"),
43-
new = adjust_row(hunk.index_from, offset, hunk.lines, "-"),
42+
old = M.adjust_row(hunk.disk_from, offset, hunk.lines, "+"),
43+
new = M.adjust_row(hunk.index_from, offset, hunk.lines, "-"),
4444
line = hunk.lines[offset] or "",
4545
}
4646
end

0 commit comments

Comments
 (0)