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 12, 2024
1 parent 4003847 commit a2f7931
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 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,16 @@ 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
path_norm = path_norm:gsub("^modified ", "")
path_norm = path_norm:gsub("^renamed ", "")
path_norm = path_norm:gsub("^new file ", "")
path_norm = path_norm:gsub("^deleted file ", "")
-- 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 a2f7931

Please sign in to comment.