# editor: Add optional cursor movement animation \(\#63195\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/2988a592412194ff8c9be35734bf117f52dab9c4)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 2988a592412194ff8c9be35734bf117f52dab9c4

Requested commit: 2988a592412194ff8c9be35734bf117f52dab9c4

Commit: 2988a592412194ff8c9be35734bf117f52dab9c4

Tree: 7f9b2b324a668b3824e20c7066c992d05d0367bb

Author: Cain

Committer: GitHub

## Message

````
editor: Add optional cursor movement animation (#63195)

# Objective

Add an optional smooth cursor movement animation to make cursor position
changes easier to follow, especially during larger jumps and
multi-cursor editing.

Related to #4991.

## Solution

- Add a new `cursor_animation.enabled` editor setting, disabled by
default.
- Animate local bar and block cursors using a damped spring while
preserving momentum during rapid cursor movement.
- Support multiple local cursors independently.
- Continue using the cursor color provided by the active theme.
- Snap immediately when scrolling, resizing, or other viewport changes
would make interpolation misleading.
- Respect the `reduce_motion` setting.
- Request animation frames only while an enabled cursor animation is
active.

Enabling the feature causes additional editor redraws while the cursor
is moving, so it is opt-in and the performance cost is mentioned in the
setting documentation.

### Attribution

The cursor spring physics and four-corner deformation algorithm are
adapted from
[vscode-neovide-cursor](https://github.com/LengineerC/vscode-neovide-cursor),
which is available under the MIT License and inspired by Neovide.

The implementation adapts the algorithm to Zed's editor and GPUI
architecture, including viewport handling, selection state
reconciliation, multi-cursor support, theme integration, and
reduced-motion behavior. The attribution and license information are
also retained in the source file.

## Testing

Automated checks run on Windows:

- `cargo fmt --all --check`
- `cargo test -p editor cursor_animation --lib`
  - 15 cursor animation tests passed.

The tests cover:

- Spring convergence.
- Short and long cursor movements.
- Mid-animation retargeting and momentum preservation.
- Multiple independent cursors.
- Selection replacement and state cleanup.
- Viewport and scroll changes.
- Invalid or unusually large timing values.
- Supported cursor shapes.

To test manually:

1. Add the following to the settings file:

   ```json
   "cursor_animation": {
     "enabled": true
   }
   ```

2. Move the cursor using typing, arrow keys, mouse clicks, and
multi-cursor actions.
3. Toggle the setting off and confirm that cursor rendering immediately
returns to its normal behavior.

Manual testing was performed on Windows and Linux using a release build
from this exact PR branch.

Verified that:

- Cursor animation is disabled by default.
- Enabling `cursor_animation.enabled` is hot-reloaded without restarting
Zed.
- Disabling the setting immediately restores the original cursor
behavior.
- Cursor movement remains responsive during typing, keyboard navigation,
and mouse navigation.

This exact PR branch has not yet been manually tested on macOS.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

## Showcase


https://github.com/user-attachments/assets/17450529-491e-4982-b539-c46e3d5df467

---

Release Notes:

- Added an optional cursor movement animation setting.

---------

Co-authored-by: Christopher Biscardi <chris@christopherbiscardi.com>
````

## Parents

- [d9141a3fa6e6d7bf7bbc96a071e145024f7146a4](https://git.cafe/gitcafe/zed/commit/d9141a3fa6e6d7bf7bbc96a071e145024f7146a4?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/2988a592412194ff8c9be35734bf117f52dab9c4?format=markdown)
