@@ -193,13 +193,16 @@ type private FSharpProjectOptionsReactor(checker: FSharpChecker) =
193193 let rec tryComputeOptionsBySingleScriptOrFile ( document : Document ) ( ct : CancellationToken ) userOpName =
194194 async {
195195 let! fileStamp = document.GetTextVersionAsync( ct) |> Async.AwaitTask
196+ let textViewAndCaret () : ( IVsTextView * Position ) option = document.TryGetTextViewAndCaretPos()
196197
197198 match singleFileCache.TryGetValue( document.Id) with
198199 | false , _ ->
199200 let! sourceText = document.GetTextAsync( ct) |> Async.AwaitTask
200201
201202 let getProjectOptionsFromScript textViewAndCaret =
202- match textViewAndCaret with
203+ let caret = textViewAndCaret ()
204+
205+ match caret with
203206 | None ->
204207 checker.GetProjectOptionsFromScript(
205208 document.FilePath,
@@ -219,7 +222,6 @@ type private FSharpProjectOptionsReactor(checker: FSharpChecker) =
219222 userOpName = userOpName
220223 )
221224
222- let textViewAndCaret = document.TryGetTextViewAndCaretPos()
223225 let! scriptProjectOptions , _ = getProjectOptionsFromScript textViewAndCaret
224226 let project = document.Project
225227
@@ -259,7 +261,7 @@ type private FSharpProjectOptionsReactor(checker: FSharpChecker) =
259261
260262 let updateProjectOptions () =
261263 async {
262- let! scriptProjectOptions , _ = getProjectOptionsFromScript None
264+ let! scriptProjectOptions , _ = getProjectOptionsFromScript textViewAndCaret
263265
264266 checker.NotifyFileChanged( document.FilePath, scriptProjectOptions)
265267 |> Async.Start
@@ -274,7 +276,7 @@ type private FSharpProjectOptionsReactor(checker: FSharpChecker) =
274276 match value with
275277 | projectId, fileStamp, parsingOptions, projectOptions, _ ->
276278 let subscription =
277- match textViewAndCaret with
279+ match textViewAndCaret () with
278280 | Some( textView, _) ->
279281 subscribeToTextViewEvents ( textView, ( Some onChangeCaretHandler), ( Some onKillFocus), ( Some onSetFocus))
280282 | None -> None
0 commit comments