From dba993eacc152db9983e97475125cca1a96bebf1 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Thu, 16 Jun 2022 18:55:38 +0200 Subject: [PATCH 1/3] Workaroud for emptying FSharp.Editor cache due to duplicate PS events --- .../FSharp.Editor/LanguageService/LanguageService.fs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs b/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs index 777215a3e83..4cb6354946a 100644 --- a/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs +++ b/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs @@ -346,7 +346,7 @@ type internal HackCpsCommandLineChanges /// This handles commandline change notifications from the Dotnet Project-system /// Prior to VS 15.7 path contained path to project file, post 15.7 contains target binpath /// binpath is more accurate because a project file can have multiple in memory projects based on configuration - member _.HandleCommandLineChanges(path:string, sources:ImmutableArray, _references:ImmutableArray, options:ImmutableArray) = + member _.HandleCommandLineChanges(path:string, sources:ImmutableArray, references:ImmutableArray, options:ImmutableArray) = use _logBlock = Logger.LogBlock(LogEditorFunctionId.LanguageService_HandleCommandLineArgs) let projectId = @@ -363,5 +363,11 @@ type internal HackCpsCommandLineChanges let sourcePaths = sources |> Seq.map(fun s -> getFullPath s.Path) |> Seq.toArray - let workspaceService = workspace.Services.GetRequiredService() - workspaceService.FSharpProjectOptionsManager.SetCommandLineOptions(projectId, sourcePaths, options) + /// Due to an issue in project system, when we close and reopen solution, it sends is the CommandLineChanges twice for every project. + /// First time it sends a correct path, sources, references and options. + /// Second time it sends a correct path, empty sources, empty references and empty options, and we rewrite our cache, and fail to colourize the document later. + /// As a woraround, until we have a fix from PS or will move to Roslyn as a source of truth, we will not overwrite the cache in case of empty lists. + + if not (sources.IsEmpty && references.IsEmpty && options.IsEmpty) then + let workspaceService = workspace.Services.GetRequiredService() + workspaceService.FSharpProjectOptionsManager.SetCommandLineOptions(projectId, sourcePaths, options) From 61689915bae8b08c64a6e39f82a7b7d53a397681 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Fri, 17 Jun 2022 12:41:52 +0200 Subject: [PATCH 2/3] Update vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs Co-authored-by: Petr Semkin --- .../src/FSharp.Editor/LanguageService/LanguageService.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs b/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs index 4cb6354946a..2c7e3dc27ae 100644 --- a/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs +++ b/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs @@ -363,7 +363,7 @@ type internal HackCpsCommandLineChanges let sourcePaths = sources |> Seq.map(fun s -> getFullPath s.Path) |> Seq.toArray - /// Due to an issue in project system, when we close and reopen solution, it sends is the CommandLineChanges twice for every project. + /// Due to an issue in project system, when we close and reopen solution, it sends the CommandLineChanges twice for every project. /// First time it sends a correct path, sources, references and options. /// Second time it sends a correct path, empty sources, empty references and empty options, and we rewrite our cache, and fail to colourize the document later. /// As a woraround, until we have a fix from PS or will move to Roslyn as a source of truth, we will not overwrite the cache in case of empty lists. From 7c275e0dd5ed36cb099cc3c744d4cff7b01fd44b Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Fri, 17 Jun 2022 12:41:59 +0200 Subject: [PATCH 3/3] Update vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs Co-authored-by: Petr Semkin --- .../src/FSharp.Editor/LanguageService/LanguageService.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs b/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs index 2c7e3dc27ae..b50277c019b 100644 --- a/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs +++ b/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs @@ -366,7 +366,7 @@ type internal HackCpsCommandLineChanges /// Due to an issue in project system, when we close and reopen solution, it sends the CommandLineChanges twice for every project. /// First time it sends a correct path, sources, references and options. /// Second time it sends a correct path, empty sources, empty references and empty options, and we rewrite our cache, and fail to colourize the document later. - /// As a woraround, until we have a fix from PS or will move to Roslyn as a source of truth, we will not overwrite the cache in case of empty lists. + /// As a workaround, until we have a fix from PS or will move to Roslyn as a source of truth, we will not overwrite the cache in case of empty lists. if not (sources.IsEmpty && references.IsEmpty && options.IsEmpty) then let workspaceService = workspace.Services.GetRequiredService()