mirror of
https://github.com/TimUntersberger/neogit
synced 2024-09-16 14:24:09 +02:00
feat: Enable commit inspection for recent commits and stashes.
Adjusts the diff parser to handle the combined diff format (used for i.e. merge commits and stashes).
This commit is contained in:
parent
24b7a773e4
commit
c94549f3c3
2 changed files with 11 additions and 4 deletions
|
@ -50,7 +50,7 @@ local function parse_diff(output, with_stats)
|
|||
local header = {}
|
||||
|
||||
for i=start_idx,#output do
|
||||
if output[i]:match('^@@.*@@') then
|
||||
if output[i]:match('^@@@*.*@@@*') then
|
||||
start_idx = i
|
||||
break
|
||||
end
|
||||
|
@ -86,7 +86,14 @@ local function parse_diff(output, with_stats)
|
|||
for i=1,len do
|
||||
local line = diff.lines[i]
|
||||
if not vim.startswith(line, "+++") then
|
||||
local index_from, index_len, disk_from, disk_len = line:match('@@ %-(%d+),?(%d*) %+(%d+),?(%d*) @@')
|
||||
local index_from, index_len, disk_from, disk_len
|
||||
if vim.startswith(line, "@@@") then
|
||||
-- Combined diff header
|
||||
index_from, index_len, disk_from, disk_len = line:match('@@@* %-(%d+),?(%d*) .* %+(%d+),?(%d*) @@@*')
|
||||
else
|
||||
-- Normal diff header
|
||||
index_from, index_len, disk_from, disk_len = line:match('@@ %-(%d+),?(%d*) %+(%d+),?(%d*) @@')
|
||||
end
|
||||
|
||||
if index_from then
|
||||
if hunk ~= nil then
|
||||
|
|
|
@ -804,11 +804,11 @@ local cmd_func_map = function ()
|
|||
local relpath = vim.fn.fnamemodify(repo_root .. '/' .. path, ':.')
|
||||
|
||||
vim.cmd("e " .. relpath)
|
||||
elseif section.name == "unpulled" or section.name == "unmerged" then
|
||||
elseif vim.tbl_contains({ "unmerged", "unpulled", "recent", "stashes" }, section.name) then
|
||||
if M.commit_view and M.commit_view.is_open then
|
||||
M.commit_view:close()
|
||||
end
|
||||
M.commit_view = CommitView.new(item.name:match("(.-) "), true)
|
||||
M.commit_view = CommitView.new(item.name:match("(.-):? "), true)
|
||||
M.commit_view:open()
|
||||
else
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue