summaryrefslogtreecommitdiff
path: root/internal/lsp/handlers_execute.go
blob: f2f2fac33d89925115769bbb2e49f6f46e27364d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// ExecuteCommand handler to support post-edit navigation (jump to generated test).
package lsp

import (
	"encoding/json"
)

func (s *Server) handleExecuteCommand(req Request) {
	var p ExecuteCommandParams
	if err := json.Unmarshal(req.Params, &p); err != nil {
		s.reply(req.ID, nil, nil)
		return
	}
	switch p.Command {
	case "hexai.showDocument":
		if len(p.Arguments) >= 2 {
			uri, _ := p.Arguments[0].(string)
			var r Range
			// Convert second arg to Range via re-marshal to be robust across clients
			if b, err := json.Marshal(p.Arguments[1]); err == nil {
				_ = json.Unmarshal(b, &r)
			}
			if uri != "" {
				s.clientShowDocument(uri, &r)
			}
		}
		s.reply(req.ID, nil, nil)
		return
	default:
		// Unknown command; no-op
		s.reply(req.ID, nil, nil)
		return
	}
}