@@ -37,16 +37,36 @@ func NewDiagnosticsTool(lspManager *lsp.Manager) fantasy.AgentTool {
40−func notifyLSPs(
40+// openInLSPs ensures LSP servers are running and aware of the file, but does
41+// not notify changes or wait for fresh diagnostics. Use this for read-only
42+// operations like view where the file content hasn't changed.
41 ctx context.Context,
44 ctx context.Context,
42 manager *lsp.Manager,
45 manager *lsp.Manager,
43 filepath string,
46 filepath string,
45− if filepath == "" {
48+ if filepath == "" || manager == nil {
52+ manager.Start(ctx, filepath)
54+ for client := range manager.Clients().Seq() {
55+ if !client.HandlesFile(filepath) {
58+ _ = client.OpenFileOnDemand(ctx, filepath)
62+// notifyLSPs notifies LSP servers that a file has changed and waits for
63+// updated diagnostics. Use this after edit/multiedit operations.
66+ manager *lsp.Manager,
49− if manager == nil {
69+ if filepath == "" || manager == nil {