diff --git a/vsintegration/src/FSharp.Editor/Refactor/AddExplicitReturnType.fs b/vsintegration/src/FSharp.Editor/Refactor/AddExplicitReturnType.fs index 7e836f482931..b7e8afd3ed47 100644 --- a/vsintegration/src/FSharp.Editor/Refactor/AddExplicitReturnType.fs +++ b/vsintegration/src/FSharp.Editor/Refactor/AddExplicitReturnType.fs @@ -80,8 +80,6 @@ type internal AddExplicitReturnType [] () = | _ -> None override _.ComputeRefactoringsAsync context = - let ct = context.CancellationToken - cancellableTask { let document = context.Document let position = context.Span.Start @@ -93,7 +91,8 @@ type internal AddExplicitReturnType [] () = let! lexerSymbol = document.TryFindFSharpLexerSymbolAsync(position, SymbolLookupKind.Greedy, false, false, nameof (AddExplicitReturnType)) - let! (parseFileResults, checkFileResults) = document.GetFSharpParseAndCheckResultsAsync(nameof (AddExplicitReturnType)) + let! (parseFileResults, checkFileResults) = + document.GetFSharpParseAndCheckResultsAsync(nameof (AddExplicitReturnType)) let symbolUseOpt = lexerSymbol @@ -121,5 +120,4 @@ type internal AddExplicitReturnType [] () = | _ -> () return () - } - |> CancellableTask.startAsTask ct + } |> CancellableTask.startAsTaskWithoutCancellation diff --git a/vsintegration/tests/FSharp.Editor.Tests/Refactors/AddExplicitReturnTypeTests.fs b/vsintegration/tests/FSharp.Editor.Tests/Refactors/AddExplicitReturnTypeTests.fs index 8a45b8396a62..fae889553c3c 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/Refactors/AddExplicitReturnTypeTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/Refactors/AddExplicitReturnTypeTests.fs @@ -4,6 +4,9 @@ open Microsoft.VisualStudio.FSharp.Editor open Xunit open System.Linq open FSharp.Editor.Tests.Refactors.RefactorTestFramework +open FSharp.Test.ProjectGeneration +open FSharp.Editor.Tests.Helpers +open System.Threading [] [] @@ -181,18 +184,31 @@ let ``Correctly infer custom type that is declared earlier in project`` () = let myModule = """ -module MyModule type MyType = { Value: int } """ let code = """ -open MyModule +open ModuleFirst let sum a b = {Value=a+b} """ - use context = TestContext.CreateWithCodeAndDependency code myModule + let project = + SyntheticProject.Create( + { sourceFile "First" [] with + Source = myModule + SignatureFile = AutoGenerated + }, + { sourceFile "Second" ["First"] with + Source = code + } + ) + + project.SaveAndCheck() |> ignore + let solution, _ = RoslynTestHelpers.CreateSolution project + let ct = CancellationToken false + let context = new TestContext(solution, ct) let spanStart = code.IndexOf symbolName