Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(commit-view): fix jump to file, when filenames contain - #1595

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading