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

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:

<img width="967" height="772" alt="Screenshot from 2026-04-07 08-46-10"
src="https://github.com/user-attachments/assets/a6b2aa2b-03f7-4abf-a4c4-c87d41df83ae"
/>


After:

<img width="1245" height="993" alt="Screenshot from 2026-04-07 08-23-32"
src="https://github.com/user-attachments/assets/27ef2487-d7fd-4a73-93e5-97fc719f9245"
/>

<img width="1245" height="993" alt="Screenshot from 2026-04-07 08-23-40"
src="https://github.com/user-attachments/assets/1b1daf80-544d-4128-bc92-b7d44b8d6564"
/>

<img width="963" height="636" alt="Screenshot from 2026-04-07 08-23-53"
src="https://github.com/user-attachments/assets/bb244ce9-797e-4a5f-b48f-eb0e4b982f7d"
/>

---

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.

Co-authored-by: dino <dinojoaocosta@gmail.com>
9affe8cbacValery Borovsky committed on 4/23/2026, 10:46:52 AM· committed by GitHubparent9494586
2 files changedLine totals unavailable