Skip to content

editor: Fix sticky scroll showing decorator line instead of declaration#53288

Merged
ConradIrwin merged 2 commits intozed-industries:mainfrom
Vastargazing:fix/issue-49466-php-sticky-scroll-attributes
Apr 23, 2026
Merged

editor: Fix sticky scroll showing decorator line instead of declaration#53288
ConradIrwin merged 2 commits intozed-industries:mainfrom
Vastargazing:fix/issue-49466-php-sticky-scroll-attributes

Conversation

@Vastargazing
Copy link
Copy Markdown
Contributor

@Vastargazing Vastargazing commented Apr 7, 2026

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_declaration as a child node, so sticky headers were previously taking their start from item.range.start and getting stuck on the #[Deprecated] line instead of function foo(). Switching to source_range_for_text.start fixes 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 #49466


Before:

Screenshot from 2026-04-07 08-46-10

After:

Screenshot from 2026-04-07 08-23-32 Screenshot from 2026-04-07 08-23-40 Screenshot from 2026-04-07 08-23-53

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:

  • Fixed sticky scroll headers showing attribute/decorator lines instead of the declaration line in PHP and other languages where annotations are child nodes of the declaration.

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
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Apr 7, 2026
@zed-codeowner-coordinator zed-codeowner-coordinator Bot requested review from a team, as-cii and dinocosta and removed request for a team April 7, 2026 05:53
@maxdeviant maxdeviant changed the title editor: fix sticky scroll showing decorator line instead of declaration editor: Fix sticky scroll showing decorator line instead of declaration Apr 7, 2026
Copy link
Copy Markdown
Member

@ConradIrwin ConradIrwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

@ConradIrwin ConradIrwin enabled auto-merge (squash) April 20, 2026 17:40
@ConradIrwin ConradIrwin added this pull request to the merge queue Apr 23, 2026
Merged via the queue into zed-industries:main with commit 9affe8c Apr 23, 2026
31 checks passed
@jrmajor
Copy link
Copy Markdown

jrmajor commented Apr 23, 2026

Thank you @timvermeulen for the analysis and @Vastargazing for the fix!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sticky scroll in PHP shows attributes instead of function names

5 participants