aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2026-10-01 11:49:23 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2026-10-02 08:10:45 +0200
commita518f066f320075daca2fb9dbeb7d8607063ee23 (patch)
tree6fb5af41694b783f81ebcf3097ae74d67a89b108
parentc5d260a3b65cff246fbc8e3828e1f4a0c16304ba (diff)
downloadvis-lspc-a518f066f320075daca2fb9dbeb7d8607063ee23.tar.gz
vis-lspc-a518f066f320075daca2fb9dbeb7d8607063ee23.zip
Handle writes to closed language-server pipes
A language server can exit and close its communication pipe before vis-lspc sends its next RPC message. The resulting Lua file-handle error escapes the RPC function and interrupts editing. Catch failures from write and flush, log the server name and error, and return false instead.
-rw-r--r--init.lua11
1 files changed, 9 insertions, 2 deletions
diff --git a/init.lua b/init.lua
index 447b9bb..383d599 100644
--- a/init.lua
+++ b/init.lua
@@ -668,8 +668,15 @@ function LanguageServer:rpc(req)
local msg = header_part .. '\r\n\r\n' .. content_part
lspc:log('LSPC Sending -> ' .. self.name .. ': ' .. msg)
- self.fd:write(msg)
- self.fd:flush()
+ local ok, err = pcall(function()
+ self.fd:write(msg)
+ self.fd:flush()
+ end)
+ if not ok then
+ lspc:warn('Could not send message to ' .. self.name .. ': ' .. tostring(err))
+ return false
+ end
+ return true
end
--- Send a RPC notification to the language server