The caret's glide is a setting, not a hard-coded on - #712
Merged
Conversation
`cursorSmoothCaretAnimation: 'on'` sat in the `monaco.editor.create()` literal, so the caret's slide between positions was the only motion in the app with no way to turn it off — `animateJumpScroll` already answers for the animated jump in both panes. Its own preference rather than a second reader of `animateJumpScroll`: a jump is the app moving the view on the user's behalf a few times a session, and the glide is drawn under every arrow key. Someone who finds the glide smeary has no reason to lose the animated jump with it. The option moves into `editorOptionsFromSettings` for the reason `smoothScrolling` moved there — the set `updateOptions` re-applies is what makes a toggle reach the editor that is already open. Left in the creation literal it would have taken effect only on the next one. Defaults to on, so nothing about an existing install changes, and it answers `prefers-reduced-motion` through the same predicate the jump preference does: either voice asking for less motion is enough.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this is
Adds Animate Cursor Movement to Settings → Appearance, directly under
Animate Scrolling on Jump. Closes #710, reported by @eli-yip, who found
cursorSmoothCaretAnimationhard-coded and asked for the same treatment thescroll animation already gets.
Defaults to on, so nothing about an existing install changes.
Mechanism
cursorSmoothCaretAnimation: 'on'was a literal in themonaco.editor.create()call in
Editor.svelte. That made the caret's slide between positions the onlymotion in the app with no switch:
animateJumpScrollalready answers for theanimated jump in both panes, and the glide answered to nothing.
It is its own preference rather than a second reader of
animateJumpScroll. Ajump is the app moving the view on the user's behalf, a few times a session;
the glide is drawn under every arrow key. Someone who finds the glide smeary
has no reason to lose the animated jump along with it. The alternative —
folding both into one "reduce animation" switch — was rejected for that reason,
and because the issue asks for a switch similar to the existing one, not a
change to what the existing one covers.
The option moves out of the creation literal and into
editorOptionsFromSettings, for the reasonsmoothScrollingmoved thereearlier: the set
updateOptionsre-applies is what makes a toggle reach theeditor that is already open. Left where it was, the switch would have taken
effect only on the next editor — the toggle would look inert to anyone who
flipped it and went back to typing.
Both preferences resolve through one predicate in
utils/motion.ts, soprefers-reduced-motioncannot end up honoured by one and not the other. Thatis the same expression-written-twice shape the module's existing comment was
written about.
Scope
Only the main editor. The other Monaco instance, the diff view in
DiffOverlay.svelte, isreadOnly: trueand never set the option, so it hasno caret to animate. The preview pane is rendered output with no editable
surface, and the app's
<input>fields use the native caret, which Monaco doesnot reach.
No version bump, no changes to the jump-scroll preference or its call sites.
Tests
Four assertions in
editorOptionWiring.test.ts, all behavioural — they calleditorOptionsFromSettingsrather than matching source text:'on''off'systemReducedMotionalone resolves to'off', with the app setting still onanimateJumpScroll: falseleaves the caret at'on'— the two are independentRevert check: restoring the hard-coded
'on'ineditorOptionsFromSettingsand keeping the tests turns the new test red and leaves the other 971 green.
The existing assertion that pins the exact set of options both call sites share
gains
cursorSmoothCaretAnimation. That is the assertion doing its job: it isthere so an option cannot quietly enter or leave the shared set, and this change
deliberately puts one in.
Verification
Manually verified on macOS 15 in a release build: the toggle changes the caret
in the open editor with no restart, survives a relaunch, leaves the animated
jump working when it is off, and both animations stop when the system's Reduce
Motion is on while both switches stay on in the UI.
Not verified: Windows and Linux. The change is one Monaco option and a
localStoragekey, with no platform-conditional path, so I reasoned aboutthose rather than running them.