Skip to content

Conversation

@acardonna
Copy link
Contributor

@acardonna acardonna commented Nov 23, 2025

This PR adds several changes to improve the current state of the outline for multiple Java pieces of code. This will not only be reflected in the outline panel, but also in the buffer symbols, which in my case, is what I prefer to navigate across all the symbols in the current file. At the beginning, my motivation was to solve an issue related to how the methods were appearing in the sticky scroll, but this led me a rabbit hole where I discovered that a lot more was missing in the outline, namely the following:

Things that didn't appear in the outline before:

  1. Constructors.
  2. Any classinterfaceenumrecord and annotation (even if nested) that had no modifiers (access and non-access).
  3. Fields and methods that had no modifiers (access and non-access).
  4. Static blocks.
  5. The types of the fields and the return type of methods.
  6. Enum declaration.
  7. Enum constants.
  8. Annotation type declaration.
  9. Annotation type elements.
  10. The constant fields of an interface.
  11. The parameters of a record constructor.

And lastly, these changes have as consequence also the fixing of an issue related to the sticky scroll. The purpose of the sticky scroll is to give you context about the class and the method you are currently in, which can be very useful in multiple scenarios. However, there was an issue that when a method or class had an annotation, that annotation would appear in the sticky scroll instead of the whole method declaration, defeating the purpose of the sticky scroll.

This feature was recently introduced and can be enabled in settings.json:

    "sticky_scroll": {
        "enabled": true
    }

Limitations I found:

  1. Currently, there's always a space after a parameter type in the outline. Even before these changes, when a method had parameters, even though the parameter types were not shown, there was a space left inside the parenthesis. After trying to solve this with no success, I'm very inclined to believe this is probably an issue on Zed's side.
  2. For records, the constructor parameters appear at the top level in the outline. To nest them under the record declaration, we need the entire record_declaration marked as @item, but marking the entire record_declaration as @item causes the sticky scroll to show the annotation (because it includes the entire text range starting with any annotation that is present).

Before:

before.mov

Now:

now.mov

@cla-bot cla-bot bot added the cla-signed label Nov 23, 2025
@tartarughina
Copy link
Collaborator

Thanks for the deep dive and for improving the state of outline.

I'll try out your changes even though the PR already looks good, or rather, there's nothing that stands out.

About the video. Let's make it a nice to have for those instances where the dynamic behavior needs to be conveyed, otherwise, a side-by-side image of the before and after is plenty enough.

Copy link
Collaborator

@tartarughina tartarughina left a comment

Choose a reason for hiding this comment

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

I was testing the sticky behavior for annotations.
While for methods it works perfectly, it doesn't for classes.
The sticky element is the annotation rather than the class.

@acardonna
Copy link
Contributor Author

@tartarughina Thank you so much for spotting that issue! I made the fixes and now it should be working correctly. I also updated the PR description to include a visualization of the changes. Let me know what you think :).

Copy link
Collaborator

@playdohface playdohface left a comment

Choose a reason for hiding this comment

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

It works for me now, thanks for another great contribution @acardonna

@playdohface playdohface merged commit b58e22f into zed-extensions:main Nov 24, 2025
1 check passed
@acardonna acardonna deleted the improve-outline branch November 24, 2025 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants