MCPcopy
hub / github.com/claude-code-best/claude-code / closeFile

Function closeFile

src/services/lsp/LSPServerManager.ts:379–402  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

getServerForFileFunction · 0.85
deleteMethod · 0.65
logForDebuggingFunction · 0.50
errorMessageFunction · 0.50
logErrorFunction · 0.50
resolveMethod · 0.45

Tested by

no test coverage detected