aboutsummaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-08-29 17:48:52 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2023-08-29 17:48:52 +0200
commitb1db5ae2a8aeeb72dca127e62d5cbf5b3c7caced (patch)
tree1edc666f72cb87ef164508de2f7fa0a408472763 /init.lua
parent5d8801804180f7f0ab09b97bbdf8ae41e619c759 (diff)
downloadvis-lspc-b1db5ae2a8aeeb72dca127e62d5cbf5b3c7caced.tar.gz
vis-lspc-b1db5ae2a8aeeb72dca127e62d5cbf5b3c7caced.zip
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
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua5
1 files changed, 4 insertions, 1 deletions
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)