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