mirror of
https://github.com/lukaszraczylo/filepuff-mcp.git
synced 2026-10-17 05:47:33 +00:00
fixup! Update, bugfixes on diff and edit handling
This commit is contained in:
@@ -268,7 +268,11 @@ func (c *Client) send(msg interface{}) error {
|
||||
}
|
||||
|
||||
// readLoop reads and dispatches messages from the server.
|
||||
// On exit (for any reason), it drains all pending Call waiters with a
|
||||
// synthetic error so that goroutines blocked in Call are unblocked.
|
||||
func (c *Client) readLoop() {
|
||||
defer c.drainPending()
|
||||
|
||||
reader := bufio.NewReader(c.stdout)
|
||||
|
||||
for {
|
||||
@@ -329,6 +333,25 @@ func (c *Client) readLoop() {
|
||||
}
|
||||
}
|
||||
|
||||
// drainPending sends a synthetic error response to every pending Call waiter
|
||||
// so that goroutines blocked in Call are unblocked when readLoop exits.
|
||||
func (c *Client) drainPending() {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
|
||||
for id, ch := range c.pending {
|
||||
ch <- &Response{
|
||||
JSONRPC: "2.0",
|
||||
ID: id,
|
||||
Error: &ResponseError{
|
||||
Code: -32603, // InternalError
|
||||
Message: "LSP client readLoop terminated",
|
||||
},
|
||||
}
|
||||
delete(c.pending, id)
|
||||
}
|
||||
}
|
||||
|
||||
// IsRunning returns whether the client is running.
|
||||
func (c *Client) IsRunning() bool {
|
||||
c.runningMu.RLock()
|
||||
|
||||
Reference in New Issue
Block a user