@@ -24,7 +24,7 @@ func WriteMessage(w io.Writer, msg *Message) error {
2424 }
2525
2626 // High-level operation log
27- lspLogger .Debug ("Sending message: method=%s id=%d " , msg .Method , msg .ID )
27+ lspLogger .Debug ("Sending message: method=%s id=%v " , msg .Method , msg .ID )
2828
2929 // Wire protocol log (more detailed)
3030 wireLogger .Debug ("-> Sending: %s" , string (data ))
@@ -83,12 +83,12 @@ func ReadMessage(r *bufio.Reader) (*Message, error) {
8383 }
8484
8585 // Log higher-level information about the message type
86- if msg .Method != "" && msg .ID != 0 {
87- lspLogger .Debug ("Received request from server: method=%s id=%d " , msg .Method , msg .ID )
86+ if msg .Method != "" && msg .ID != nil && msg . ID . Value != nil {
87+ lspLogger .Debug ("Received request from server: method=%s id=%v " , msg .Method , msg .ID )
8888 } else if msg .Method != "" {
8989 lspLogger .Debug ("Received notification: method=%s" , msg .Method )
90- } else if msg .ID != 0 {
91- lspLogger .Debug ("Received response for ID: %d " , msg .ID )
90+ } else if msg .ID != nil && msg . ID . Value != nil {
91+ lspLogger .Debug ("Received response for ID: %v " , msg .ID )
9292 }
9393
9494 return & msg , nil
@@ -109,7 +109,7 @@ func (c *Client) handleMessages() {
109109 }
110110
111111 // Handle server->client request (has both Method and ID)
112- if msg .Method != "" && msg .ID != 0 {
112+ if msg .Method != "" && msg .ID != nil && msg . ID . Value != nil {
113113 response := & Message {
114114 JSONRPC : "2.0" ,
115115 ID : msg .ID ,
@@ -121,7 +121,7 @@ func (c *Client) handleMessages() {
121121 c .serverHandlersMu .RUnlock ()
122122
123123 if ok {
124- lspLogger .Debug ("Processing server request: method=%s id=%d " , msg .Method , msg .ID )
124+ lspLogger .Debug ("Processing server request: method=%s id=%v " , msg .Method , msg .ID )
125125 result , err := handler (msg .Params )
126126 if err != nil {
127127 lspLogger .Error ("Error handling server request %s: %v" , msg .Method , err )
@@ -158,7 +158,7 @@ func (c *Client) handleMessages() {
158158 }
159159
160160 // Handle notification (has Method but no ID)
161- if msg .Method != "" && msg .ID == 0 {
161+ if msg .Method != "" && ( msg .ID == nil || msg . ID . Value == nil ) {
162162 c .notificationMu .RLock ()
163163 handler , ok := c .notificationHandlers [msg .Method ]
164164 c .notificationMu .RUnlock ()
@@ -173,17 +173,19 @@ func (c *Client) handleMessages() {
173173 }
174174
175175 // Handle response to our request (has ID but no Method)
176- if msg .ID != 0 && msg .Method == "" {
176+ if msg .ID != nil && msg .ID .Value != nil && msg .Method == "" {
177+ // Convert ID to string for map lookup
178+ idStr := msg .ID .String ()
177179 c .handlersMu .RLock ()
178- ch , ok := c .handlers [msg . ID ]
180+ ch , ok := c .handlers [idStr ]
179181 c .handlersMu .RUnlock ()
180182
181183 if ok {
182- lspLogger .Debug ("Sending response for ID %d to handler" , msg .ID )
184+ lspLogger .Debug ("Sending response for ID %v to handler" , msg .ID )
183185 ch <- msg
184186 close (ch )
185187 } else {
186- lspLogger .Debug ("No handler for response ID: %d " , msg .ID )
188+ lspLogger .Debug ("No handler for response ID: %v " , msg .ID )
187189 }
188190 }
189191 }
@@ -193,7 +195,7 @@ func (c *Client) handleMessages() {
193195func (c * Client ) Call (ctx context.Context , method string , params any , result any ) error {
194196 id := c .nextID .Add (1 )
195197
196- lspLogger .Debug ("Making call: method=%s id=%d " , method , id )
198+ lspLogger .Debug ("Making call: method=%s id=%v " , method , id )
197199
198200 msg , err := NewRequest (id , method , params )
199201 if err != nil {
@@ -202,13 +204,15 @@ func (c *Client) Call(ctx context.Context, method string, params any, result any
202204
203205 // Create response channel
204206 ch := make (chan * Message , 1 )
207+ // Convert ID to string for map lookup
208+ idStr := msg .ID .String ()
205209 c .handlersMu .Lock ()
206- c .handlers [id ] = ch
210+ c .handlers [idStr ] = ch
207211 c .handlersMu .Unlock ()
208212
209213 defer func () {
210214 c .handlersMu .Lock ()
211- delete (c .handlers , id )
215+ delete (c .handlers , idStr )
212216 c .handlersMu .Unlock ()
213217 }()
214218
@@ -217,12 +221,12 @@ func (c *Client) Call(ctx context.Context, method string, params any, result any
217221 return fmt .Errorf ("failed to send request: %w" , err )
218222 }
219223
220- lspLogger .Debug ("Waiting for response to request ID: %d " , id )
224+ lspLogger .Debug ("Waiting for response to request ID: %v " , msg . ID )
221225
222226 // Wait for response
223227 resp := <- ch
224228
225- lspLogger .Debug ("Received response for request ID: %d " , id )
229+ lspLogger .Debug ("Received response for request ID: %v " , msg . ID )
226230
227231 if resp .Error != nil {
228232 lspLogger .Error ("Request failed: %s (code: %d)" , resp .Error .Message , resp .Error .Code )
0 commit comments