Skip to content

fixed: git rename not showing up for the renamed file #1783

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

Merged
merged 4 commits into from
Dec 3, 2022
Merged
Changes from 1 commit
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
Next Next commit
fixed git rename not showing up for the renamed file
  • Loading branch information
chomosuke committed Nov 29, 2022
commit f2c3c6f715f0e1bccdba515739f55e15d4d76ee0
11 changes: 10 additions & 1 deletion lua/nvim-tree/git/runner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@ Runner.__index = Runner

function Runner:_parse_status_output(line)
local status = line:sub(1, 2)
local path = line:sub(4, -2)
if utils.str_find(status, "R") then
-- rename have format of "from -> to"
-- we just what the "to" part
local _, j = path:find " -> "
-- Note: The edge case where " -> " is a part of a file name is not addressed
path = path:sub(j + 1, -1)
end

-- removing `"` when git is returning special file status containing spaces
local path = line:sub(4, -2):gsub('^"', ""):gsub('"$', "")
path = path:gsub('^"', ""):gsub('"$', "")
-- replacing slashes if on windows
if vim.fn.has "win32" == 1 then
path = path:gsub("/", "\\")
Expand Down