editor: Fix sticky scroll showing decorator line instead of declaration#53288
Merged
ConradIrwin merged 2 commits intozed-industries:mainfrom Apr 23, 2026
Conversation
When a language's @item node includes annotation/attribute children before its first @context capture (e.g. PHP's attribute_list inside function_declaration, TypeScript's decorator inside class_declaration), the sticky scroll header displayed the annotation line rather than the declaration keyword line. Fix by using source_range_for_text.start (position of the first @context/@name capture) instead of item.range.start (the full @item node start) when computing the sticky scroll display row. Fixes: zed-industries#49466
|
Thank you @timvermeulen for the analysis and @Vastargazing for the fix! |
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.
Fixes #49466
It looks like this wasn't actually a bug in the PHP outline query, but a general sticky scroll bug. In PHP, the attribute ends up inside the
function_declarationas a child node, so sticky headers were previously taking their start fromitem.range.startand getting stuck on the#[Deprecated]line instead offunction foo(). Switching tosource_range_for_text.startfixes exactly that, and also covers other languages that put decorators or attributes before the declaration. I added the test in TypeScript because it has the same tree shape and covers the same class of bug as #49466Before:
After:
Tests:
Nextest run ID f0de6791-1a3c-406b-9589-54df870b832b with nextest profile: default
Starting 3 tests across 1 binary (655 tests skipped)
PASS [ 0.986s] (1/3) editor editor_tests::test_sticky_scroll
PASS [ 0.436s] (2/3) editor editor_tests::test_sticky_scroll_with_decoration_prefix_in_item
PASS [ 0.822s] (3/3) editor editor_tests::test_sticky_scroll_with_expanded_deleted_diff_hunks
────────────
Summary [ 2.298s] 3 tests run: 3 passed, 655 skipped
Release Notes: