Skip to content

editor: Clear previous select mode when clicking on a sticky header#52636

Merged
cole-miller merged 2 commits intozed-industries:mainfrom
timvermeulen:sticky-header-click-clear-selections
Apr 1, 2026
Merged

editor: Clear previous select mode when clicking on a sticky header#52636
cole-miller merged 2 commits intozed-industries:mainfrom
timvermeulen:sticky-header-click-clear-selections

Conversation

@timvermeulen
Copy link
Copy Markdown
Contributor

Clicking on a sticky header causes selections.select_ranges([anchor..anchor]) to be called, but this does not clear the editor's selections.select_mode(), resulting in possible incorrect selections if this is followed up by a shift-click. This PR fixes that with

- selections.select_ranges([anchor..anchor]);
+ selections.clear_disjoint();
+ selections.set_pending_anchor_range(anchor..anchor, SelectMode::Character);

which is essentially what editor.select(SelectPhase::Begin { ... }, ...) (i.e. a regular single click in the editor) does as well.

Before:

before.mov

After:

after.mov

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content is consistent with the UI/UX checklist
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Release Notes:

  • Fixed bug that caused clicking on a sticky header to not always properly clear the previous selection.

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Mar 28, 2026
@github-actions github-actions Bot added the community champion Issues filed by our amazing community champions! 🫶 label Mar 28, 2026
@zed-codeowner-coordinator zed-codeowner-coordinator Bot requested review from a team, Anthony-Eid and cole-miller and removed request for a team March 28, 2026 19:38
@cole-miller
Copy link
Copy Markdown
Member

Thanks!

@cole-miller cole-miller enabled auto-merge (squash) April 1, 2026 14:19
@cole-miller cole-miller merged commit dcef83e into zed-industries:main Apr 1, 2026
33 checks passed
@cole-miller
Copy link
Copy Markdown
Member

cole-miller commented Apr 1, 2026

@zed-zippy approved

@timvermeulen timvermeulen deleted the sticky-header-click-clear-selections branch April 2, 2026 00:10
piper-of-dawn pushed a commit to piper-of-dawn/zed that referenced this pull request Apr 25, 2026
…ed-industries#52636)

Clicking on a sticky header causes
`selections.select_ranges([anchor..anchor])` to be called, but this does
not clear the editor's `selections.select_mode()`, resulting in possible
incorrect selections if this is followed up by a shift-click. This PR
fixes that with
```diff
- selections.select_ranges([anchor..anchor]);
+ selections.clear_disjoint();
+ selections.set_pending_anchor_range(anchor..anchor, SelectMode::Character);
```
which is essentially what `editor.select(SelectPhase::Begin { ... },
...)` (i.e. a regular single click in the editor) does as well.

Before:


https://github.com/user-attachments/assets/bcf2647e-a22a-4866-8975-d29e135df148

After:


https://github.com/user-attachments/assets/fb82db51-fef1-4b7c-9954-6e076ae0b176

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 is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Fixed bug that caused clicking on a sticky header to not always
properly clear the previous selection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement community champion Issues filed by our amazing community champions! 🫶

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants