From 34a2e4660dcf8d606b171d70e1399ff98d310ac1 Mon Sep 17 00:00:00 2001 From: centsent Date: Tue, 31 Oct 2023 22:37:00 +0800 Subject: [PATCH] fix: do not perform arithmetic when `space_pos` is nil --- lua/lsp-lens/lens-util.lua | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lua/lsp-lens/lens-util.lua b/lua/lsp-lens/lens-util.lua index fafda17..2f172f7 100644 --- a/lua/lsp-lens/lens-util.lua +++ b/lua/lsp-lens/lens-util.lua @@ -212,13 +212,15 @@ local function get_recent_editor(start_row, end_row, callback) for line in string.gmatch(data, "[^\r\n]+") do local space_pos = string.find(line, " ") - local key = string.sub(line, 1, space_pos - 1) - local val = string.sub(line, space_pos + 1) - if key == "author" then - -- if key == "author" or key == "committer" then - authors[val] = true - if most_recent_editor == nil then - most_recent_editor = val + if space_pos ~= nil then + local key = string.sub(line, 1, space_pos - 1) + local val = string.sub(line, space_pos + 1) + if key == "author" then + -- if key == "author" or key == "committer" then + authors[val] = true + if most_recent_editor == nil then + most_recent_editor = val + end end end end