Perf: Debounce script `updateProjectOptions` (fires on every caret move)
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
## Description
In `FSharpProjectOptionsManager.fs`, `onChangeCaretHandler` calls `updateProjectOptions` on every caret position change. This in turn calls `checker.NotifyFileChanged(document.FilePath, scriptProjectOptions) |> Async.Start`, asking FCS to re-evaluate script options, potentially triggering a new parse and `#r`/`#load` resolution on every keystroke/caret move.
## Call chain
User moves caret → `IVsTextViewEvents.OnChangeCaretLine` → `onChangeCaretHandler` → `updateProjectOptions` → `Async.Start(checker.NotifyFileChanged(...))` → FCS script options resolution.
## Fix
Debounce `updateProjectOptions`: use a `CancellationTokenSource` that is swapped/cancelled on each call and only actually notifies after a 500ms idle period, implemented as a `cancellableTask` using `Task.Delay(500, ct)`.
## Priority
P2 (medium-term)
Contributor guide
Research direction
Start in FSharpProjectOptionsManager.fs at onChangeCaretHandler and follow its call to updateProjectOptions and checker.NotifyFileChanged. Read the existing cancellableTask usage and Async.Start flow first. Done means repeated caret changes cancel pending work and notification occurs only after 500ms without another change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- fsharp
- Domain
- performance, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100