Wrong location using the git_diff picker #2721
MartinDelille
started this conversation in
General
Replies: 1 comment
-
|
Not technically a bug: displayed diff context lines affect hunk header offsets (try Snacks.picker.git_diff({
transform = function(item)
if item.block and not vim.tbl_isempty(item.block.hunks) then
local ctx_offset = 0
local first_diff = item.block.hunks[1].diff
for i, line in ipairs(first_diff) do
if line:match("^%+") then
ctx_offset = i - 2
break
elseif line:match("^%-") then
ctx_offset = i - 3
break
end
end
ctx_offset = math.max(0, ctx_offset)
item.pos[1] = item.pos[1] + ctx_offset
end
return item
end,
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When using the git_diff picker, I have an issue with the location when selecting a diff. It goes 3 lines before the actual diff. I suspect this correspond to the hunk location which is generally 3 lines before the diff. Can I fix this by config ?
Beta Was this translation helpful? Give feedback.
All reactions