MCPcopy Create free account
hub / github.com/freecodexyz/free-code / closeFile

Function closeFile

src/services/lsp/LSPServerManager.ts:377–400  ·  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

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

Callers

nothing calls this directly

Calls 6

getServerForFileFunction · 0.85
logForDebuggingFunction · 0.85
resolveMethod · 0.80
deleteMethod · 0.80
errorMessageFunction · 0.50
logErrorFunction · 0.50

Tested by

no test coverage detected