Skip to content

Commit ec0fc42

Browse files
committed
fix(commit-view): fix jump to file, when filenames contain -
1 parent 5bfc499 commit ec0fc42

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lua/neogit/buffers/commit_view/init.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,16 @@ 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+
path_norm = path_norm:gsub("^modified ", "")
213+
path_norm = path_norm:gsub("^renamed ", "")
214+
path_norm = path_norm:gsub("^new file ", "")
215+
path_norm = path_norm:gsub("^deleted file ", "")
211216
-- The gsub is to work around the fact that the OverviewFiles use
212217
-- => in renames but the diff header uses ->
213-
if path:gsub(" %-> ", " => "):match(selected_path) then
218+
path_norm = path_norm:gsub(" %-> ", " => ")
219+
220+
if path_norm == selected_path then
214221
-- Save position in jumplist
215222
vim.cmd("normal! m'")
216223

0 commit comments

Comments
 (0)