* Close a file in LSP servers (sends didClose notification) * * NOTE: Currently available but not yet integrated with compact flow. * TODO: Integrate with compact - call closeFile() when compact removes files from context * This will notify LSP servers that files are no longer in active
(filePath: string)
| 375 | * This will notify LSP servers that files are no longer in active use. |
| 376 | */ |
| 377 | async function closeFile(filePath: string): Promise<void> { |
| 378 | const server = getServerForFile(filePath) |
| 379 | if (!server || server.state !== 'running') return |
| 380 | |
| 381 | const fileUri = pathToFileURL(path.resolve(filePath)).href |
| 382 | |
| 383 | try { |
| 384 | await server.sendNotification('textDocument/didClose', { |
| 385 | textDocument: { |
| 386 | uri: fileUri, |
| 387 | }, |
| 388 | }) |
| 389 | // Remove from tracking so file can be reopened later |
| 390 | openedFiles.delete(fileUri) |
| 391 | logForDebugging(`LSP: Sent didClose for ${filePath}`) |
| 392 | } catch (error) { |
| 393 | const err = new Error( |
| 394 | `Failed to sync file close ${filePath}: ${errorMessage(error)}`, |
| 395 | ) |
| 396 | logError(err) |
| 397 | // Re-throw to propagate error to caller |
| 398 | throw err |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | function isFileOpen(filePath: string): boolean { |
| 403 | const fileUri = pathToFileURL(path.resolve(filePath)).href |
nothing calls this directly
no test coverage detected