fix: handle nil error in diff component

closes #74
This commit is contained in:
shadmansaleh 2021-10-02 15:04:14 +06:00
parent 846e5bdabf
commit b7c0a2aeb1
1 changed files with 2 additions and 2 deletions

View File

@ -169,8 +169,8 @@ function Diff.process_diff(data)
if string.find(line, [[^@@ ]]) then if string.find(line, [[^@@ ]]) then
local tokens = vim.fn.matchlist(line, [[^@@ -\v(\d+),?(\d*) \+(\d+),?(\d*)]]) local tokens = vim.fn.matchlist(line, [[^@@ -\v(\d+),?(\d*) \+(\d+),?(\d*)]])
local line_stats = { local line_stats = {
mod_count = tokens[3] == '' and 1 or tonumber(tokens[3]), mod_count = tokens[3] == nil and 0 or tokens[3] == '' and 1 or tonumber(tokens[3]),
new_count = tokens[5] == '' and 1 or tonumber(tokens[5]), new_count = tokens[5] == nil and 0 or tokens[5] == '' and 1 or tonumber(tokens[5]),
} }
if line_stats.mod_count == 0 and line_stats.new_count > 0 then if line_stats.mod_count == 0 and line_stats.new_count > 0 then