From b1db5ae2a8aeeb72dca127e62d5cbf5b3c7caced Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Tue, 29 Aug 2023 17:48:52 +0200 Subject: do not index a nil value when no formatting edits are returned The method textDocument/formatting is allowed to return null/nil which was directly passed to vis_apply_textEdits causing an exception when trying to iterate the textEdits table. Only pass the result of textDocument/formatting to vis_apply_textEdits if there is an actual result. Fixes: e83950a7149f364b653395cdd4d9446875a7f469 --- init.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 436fabe..33cb547 100644 --- a/init.lua +++ b/init.lua @@ -822,7 +822,10 @@ local function lspc_handle_rename_method_response(win, result) end local function lspc_handle_formatting_method_response(win, result) - vis_apply_textEdits(win, win.file, result) + -- The result of textDocument/formatting is defined as TextEdit[] | null + if result then + vis_apply_textEdits(win, win.file, result) + end end local function lspc_handle_initialize_response(ls, result) -- cgit v1.2.3