Skip to content

Commit 6691c4e

Browse files
authored
Merge pull request #1595 from stevenxxiu/fix/commit-view-jump
fix(commit-view): fix jump to file, when filenames contain `-`
2 parents 22de67b + 9911089 commit 6691c4e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lua/neogit/buffers/commit_view/init.lua

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,18 @@ function M:open(kind)
208208

209209
-- Search for a match and jump if we find it
210210
for path, line_nr in pairs(diff_headers) do
211+
local path_norm = path
212+
for _, kind in ipairs { "modified", "renamed", "new file", "deleted file" } do
213+
if vim.startswith(path_norm, kind .. " ") then
214+
path_norm = string.sub(path_norm, string.len(kind) + 2)
215+
break
216+
end
217+
end
211218
-- The gsub is to work around the fact that the OverviewFiles use
212219
-- => in renames but the diff header uses ->
213-
if path:gsub(" %-> ", " => "):match(selected_path) then
220+
path_norm = path_norm:gsub(" %-> ", " => ")
221+
222+
if path_norm == selected_path then
214223
-- Save position in jumplist
215224
vim.cmd("normal! m'")
216225

0 commit comments

Comments
 (0)