Skip to content

Reveal all go to definitions in the center by default#54778

Merged
SomeoneToIgnore merged 1 commit into
mainfrom
kb/reveal-center
Apr 24, 2026
Merged

Reveal all go to definitions in the center by default#54778
SomeoneToIgnore merged 1 commit into
mainfrom
kb/reveal-center

Conversation

@SomeoneToIgnore
Copy link
Copy Markdown
Contributor

@SomeoneToIgnore SomeoneToIgnore commented Apr 24, 2026

Allows to reconfigure behavior, including the previous one, top

Closes #52173

Release Notes:

  • Reworked go to definition to open its target in the center of the editor. Can be reconfigured with go_to_definition_scroll_strategy.

Allow to reconfigure behavior, including the previous one, `top`
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Apr 24, 2026
@zed-community-bot zed-community-bot Bot added the staff Pull requests authored by a current member of Zed staff label Apr 24, 2026
@SomeoneToIgnore SomeoneToIgnore added this pull request to the merge queue Apr 24, 2026
Merged via the queue into main with commit e483c3e Apr 24, 2026
42 checks passed
@SomeoneToIgnore SomeoneToIgnore deleted the kb/reveal-center branch April 24, 2026 12:45
SomeoneToIgnore pushed a commit to polyesterswing/zed that referenced this pull request Apr 29, 2026
…ries#55036)

These changes attempt to expand on the work introduced by
zed-industries#54778 by introducing a new
`GoToDefinitionScrollStrategy::Preserve` variant that attempts to keep
the cursor at the same vertical offset within the viewport when
navigating to a definition.

Most of the machinery for this was already in place. To support cases
where the user's scroll position isn't snapped to an exact display row,
for example, after scrolling with the mmouse, `Autoscroll::TopRelative`
and `Autoscroll::BottomRelative` were updated from `usize` to
`ScrollOffset`, allowing fractional offsets.

When the cursor is offscreen at the moment the `editor: go to
definition` action is invoked, `Preserve` falls back to
`Autoscroll::center`, matching the existing default for
`go_to_definition_scroll_strategy`. This avoids attempting to preserve
an offset where the cursor isn't visible which would lead to the cursor
being offscreen when jumping to the definition.

Documentation has also been updated to reflect this new strategy value.

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

Relates to zed-industries#52173

Release Notes:

- Added a new `preserve` option to `go_to_definition_scroll_strategy`
that keeps the cursor at the same vertical position within the viewport
when navigating to a definition
ebaah46 pushed a commit to ebaah46/zed that referenced this pull request May 6, 2026
…#54778)

Allows to reconfigure behavior, including the previous one, `top`

Closes zed-industries#52173

Release Notes:

- Reworked go to definition to open its target in the center of the
editor. Can be reconfigured with `go_to_definition_scroll_strategy`.
ebaah46 pushed a commit to ebaah46/zed that referenced this pull request May 6, 2026
…ries#55036)

These changes attempt to expand on the work introduced by
zed-industries#54778 by introducing a new
`GoToDefinitionScrollStrategy::Preserve` variant that attempts to keep
the cursor at the same vertical offset within the viewport when
navigating to a definition.

Most of the machinery for this was already in place. To support cases
where the user's scroll position isn't snapped to an exact display row,
for example, after scrolling with the mmouse, `Autoscroll::TopRelative`
and `Autoscroll::BottomRelative` were updated from `usize` to
`ScrollOffset`, allowing fractional offsets.

When the cursor is offscreen at the moment the `editor: go to
definition` action is invoked, `Preserve` falls back to
`Autoscroll::center`, matching the existing default for
`go_to_definition_scroll_strategy`. This avoids attempting to preserve
an offset where the cursor isn't visible which would lead to the cursor
being offscreen when jumping to the definition.

Documentation has also been updated to reflect this new strategy value.

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

Relates to zed-industries#52173

Release Notes:

- Added a new `preserve` option to `go_to_definition_scroll_strategy`
that keeps the cursor at the same vertical position within the viewport
when navigating to a definition
kathbigra pushed a commit to kathbigra/zed that referenced this pull request May 10, 2026
…#54778)

Allows to reconfigure behavior, including the previous one, `top`

Closes zed-industries#52173

Release Notes:

- Reworked go to definition to open its target in the center of the
editor. Can be reconfigured with `go_to_definition_scroll_strategy`.
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 staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Go to Definition" opens with target at the bottom of the viewport

3 participants