From b7c0a2aeb1967e5b392429c04603d487e7f86bbe Mon Sep 17 00:00:00 2001 From: shadmansaleh <13149513+shadmansaleh@users.noreply.github.com> Date: Sat, 2 Oct 2021 15:04:14 +0600 Subject: [PATCH] fix: handle nil error in diff component closes #74 --- lua/lualine/components/diff.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/lualine/components/diff.lua b/lua/lualine/components/diff.lua index 6ce5f31..f0fd098 100644 --- a/lua/lualine/components/diff.lua +++ b/lua/lualine/components/diff.lua @@ -169,8 +169,8 @@ function Diff.process_diff(data) if string.find(line, [[^@@ ]]) then local tokens = vim.fn.matchlist(line, [[^@@ -\v(\d+),?(\d*) \+(\d+),?(\d*)]]) local line_stats = { - mod_count = tokens[3] == '' and 1 or tonumber(tokens[3]), - new_count = tokens[5] == '' and 1 or tonumber(tokens[5]), + mod_count = tokens[3] == nil and 0 or tokens[3] == '' and 1 or tonumber(tokens[3]), + 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