@@ -200,13 +200,16 @@ type private FSharpProjectOptionsReactor(checker: FSharpChecker) =
200200 cancellableTask {
201201 let! ct = CancellableTask.getCancellationToken ()
202202 let! fileStamp = document.GetTextVersionAsync( ct)
203+ let textViewAndCaret () : ( IVsTextView * Position ) option = document.TryGetTextViewAndCaretPos()
203204
204205 match singleFileCache.TryGetValue( document.Id) with
205206 | false , _ ->
206207 let! sourceText = document.GetTextAsync( ct)
207208
208209 let getProjectOptionsFromScript textViewAndCaret =
209- match textViewAndCaret with
210+ let caret = textViewAndCaret ()
211+
212+ match caret with
210213 | None ->
211214 checker.GetProjectOptionsFromScript(
212215 document.FilePath,
@@ -226,7 +229,6 @@ type private FSharpProjectOptionsReactor(checker: FSharpChecker) =
226229 userOpName = userOpName
227230 )
228231
229- let textViewAndCaret = document.TryGetTextViewAndCaretPos()
230232 let! scriptProjectOptions , _ = getProjectOptionsFromScript textViewAndCaret
231233 let project = document.Project
232234
@@ -266,7 +268,7 @@ type private FSharpProjectOptionsReactor(checker: FSharpChecker) =
266268
267269 let updateProjectOptions () =
268270 async {
269- let! scriptProjectOptions , _ = getProjectOptionsFromScript None
271+ let! scriptProjectOptions , _ = getProjectOptionsFromScript textViewAndCaret
270272
271273 checker.NotifyFileChanged( document.FilePath, scriptProjectOptions)
272274 |> Async.Start
@@ -281,7 +283,7 @@ type private FSharpProjectOptionsReactor(checker: FSharpChecker) =
281283 match value with
282284 | projectId, fileStamp, parsingOptions, projectOptions, _ ->
283285 let subscription =
284- match textViewAndCaret with
286+ match textViewAndCaret () with
285287 | Some( textView, _) ->
286288 subscribeToTextViewEvents ( textView, ( Some onChangeCaretHandler), ( Some onKillFocus), ( Some onSetFocus))
287289 | None -> None
0 commit comments