From 03a3cb52664775d2f232fffba41d21c14a191df5 Mon Sep 17 00:00:00 2001 From: BooksBaum <15612932+Booksbaum@users.noreply.github.com> Date: Mon, 13 Feb 2023 13:45:47 +0100 Subject: [PATCH] Fix: Rename fails when declaration or usage in not-loaded files Incorporated from [fix](https://github.com/fsharp/FsAutoComplete/pull/1053/files#diff-febb2875fef94d7a7c78c5c23943057bc820a1f6b672f7357aee2502b51806e0R1004-R1013) in fsharp/FsAutoComplete#1053 (see https://github.com/fsharp/FsAutoComplete/pull/1037#issuecomment-1427185996) Co-authored-by: Jimmy Byrd --- .../LspServers/AdaptiveFSharpLspServer.fs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/FsAutoComplete/LspServers/AdaptiveFSharpLspServer.fs b/src/FsAutoComplete/LspServers/AdaptiveFSharpLspServer.fs index c608fc4e3..de0a5843b 100644 --- a/src/FsAutoComplete/LspServers/AdaptiveFSharpLspServer.fs +++ b/src/FsAutoComplete/LspServers/AdaptiveFSharpLspServer.fs @@ -870,9 +870,15 @@ type AdaptiveFSharpLspServer(workspaceLoader: IWorkspaceLoader, lspClient: FShar }) let getProjectOptionsForFile (filePath: string) = - openFilesToChangesAndProjectOptions - |> AMap.tryFindA filePath - |> AVal.map (Option.map snd >> Option.defaultValue []) + aval { + match! sourceFileToProjectOptions |> AMap.tryFind filePath with + | None -> + // openFilesToChangesAndProjectOptions contains script files that we may need to look through + match! openFilesToChangesAndProjectOptions |> AMap.tryFindA filePath with + | None -> return [] + | Some (_, projs) -> return projs + | Some projs -> return projs + } let autoCompleteItems: cmap * (Position -> option) * FSharp.Compiler.Syntax.ParsedInput> = cmap ()