Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When removing a file clear its diagnostics #1005

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/FsAutoComplete.Core/Commands.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1343,9 +1343,10 @@ type Commands(checker: FSharpCompilerServiceChecker, state: State, hasAnalyzers:
return CoreResponse.Res()
}

member _.FsProjRemoveFile (fsprojPath: string) (fileVirtPath: string) =
member _.FsProjRemoveFile (fsprojPath: string) (fileVirtPath: string) (fullPath: string) =
async {
FsProjEditor.removeFile fsprojPath fileVirtPath
state.RemoveProjectOptions(normalizePath fullPath)
return CoreResponse.Res()
}

Expand Down
4 changes: 4 additions & 0 deletions src/FsAutoComplete/LspServers/AdaptiveFSharpLspServer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3709,8 +3709,12 @@ type AdaptiveFSharpLspServer(workspaceLoader: IWorkspaceLoader, lspClient: FShar
>> Log.addContextDestructured "parms" p
)

let fullPath = Path.Combine(Path.GetDirectoryName p.FsProj, p.FileVirtualPath)
do! Commands.removeFile p.FsProj p.FileVirtualPath |> AsyncResult.ofCoreResponse
loadedProjectOptions |> AVal.force |> ignore
let fileUri = Path.FilePathToUri fullPath
diagnosticCollections.ClearFor fileUri

return { Content = "" }
with e ->
logger.error (
Expand Down
7 changes: 6 additions & 1 deletion src/FsAutoComplete/LspServers/FsAutoComplete.Lsp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2636,7 +2636,12 @@ type FSharpLspServer(state: State, lspClient: FSharpLspClient) =
>> Log.addContextDestructured "parms" p
)

let! res = commands.FsProjRemoveFile p.FsProj p.FileVirtualPath
let fullPath = Path.Combine(Path.GetDirectoryName p.FsProj, p.FileVirtualPath)
let! res = commands.FsProjRemoveFile p.FsProj p.FileVirtualPath fullPath
// Compute the fileUri, as this is the key used by the diagnostics collection.
let fileUri = Path.FilePathToUri fullPath

diagnosticCollections.ClearFor fileUri

let res =
match res with
Expand Down