Skip to content

Commit

Permalink
fix(commit-view): fix jump to file, when filenames contain -
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenxxiu committed Dec 13, 2024
1 parent 4003847 commit 9911089
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lua/neogit/buffers/commit_view/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,18 @@ function M:open(kind)

-- Search for a match and jump if we find it
for path, line_nr in pairs(diff_headers) do
local path_norm = path
for _, kind in ipairs { "modified", "renamed", "new file", "deleted file" } do
if vim.startswith(path_norm, kind .. " ") then
path_norm = string.sub(path_norm, string.len(kind) + 2)
break
end
end
-- The gsub is to work around the fact that the OverviewFiles use
-- => in renames but the diff header uses ->
if path:gsub(" %-> ", " => "):match(selected_path) then
path_norm = path_norm:gsub(" %-> ", " => ")

if path_norm == selected_path then
-- Save position in jumplist
vim.cmd("normal! m'")

Expand Down

0 comments on commit 9911089

Please sign in to comment.