@@ -37,16 +37,36 @@ func NewDiagnosticsTool(lspManager *lsp.Manager) fantasy.AgentTool {
3737 })
3838}
3939
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.
43+func openInLSPs(
4144 ctx context.Context,
4245 manager *lsp.Manager,
4346 filepath string,
4447) {
45− if filepath == "" {
48+ if filepath == "" || manager == nil {
4649 return
4750 }
4851
49− if manager == nil {
52+ manager.Start(ctx, filepath)
53+
54+ for client := range manager.Clients().Seq() {
55+ if !client.HandlesFile(filepath) {
56+ continue
57+ }
58+ _ = client.OpenFileOnDemand(ctx, filepath)
59+ }
60+}
61+
62+// notifyLSPs notifies LSP servers that a file has changed and waits for
63+// updated diagnostics. Use this after edit/multiedit operations.
64+func notifyLSPs(
65+ ctx context.Context,
66+ manager *lsp.Manager,
67+ filepath string,
68+) {
69+ if filepath == "" || manager == nil {
5070 return
5171 }
5272