Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions languages/ruby/outline.scm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
"module" @context
name: (_) @name) @item


(assignment
(((constant) @constant
(#match? @constant "^[A-Z\\d_]")) @name
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 Why match on digits and underscores here? They're valid inside the constant name, but not at the beginning.

Copy link
Collaborator Author

@vitallium vitallium Apr 15, 2025

Choose a reason for hiding this comment

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

That was a bold copy-and-paste from highlights.scm, I shouldn't have done it that way. I also found another case where this query matches the incorrect node in an assignment::

Category = Kernel

Such code produces two constants in the outline panel:

CleanShot 2025-04-15 at 21 04 47@2x

I think we should target places where the code assigns values to constants only:

(assignment left: (constant) @name) @item

) @item)

; Support Minitest/RSpec symbols
;
; Note that `(_)+` is used to capture one more child nodes, meaning it will also include any modifier symbols, like
Expand Down