Skip to content

Add preferPrimaryDefinition setting for go to definition#4168

Closed
sucicfilip wants to merge 1 commit into
Shopify:mainfrom
sucicfilip:feature/prefer-primary-definition
Closed

Add preferPrimaryDefinition setting for go to definition#4168
sucicfilip wants to merge 1 commit into
Shopify:mainfrom
sucicfilip:feature/prefer-primary-definition

Conversation

@sucicfilip

@sucicfilip sucicfilip commented Jul 20, 2026

Copy link
Copy Markdown

Motivation

In apps that reopen classes across many files (packwerk monoliths, engines, etc.), go to definition on a constant always opens a picker listing every reopening. Most of the time I just want the file that actually defines the class.

Implementation

Adds an opt-in featuresConfiguration.definition.preferPrimaryDefinition setting. When a constant resolves to multiple namespace entries, only the entries whose file path matches the fully qualified constant name following the Zeitwerk convention are returned (Core::Flagscore/flags.rb). If no entry matches, the behavior is unchanged. Methods and plain constants are not affected.

Automated Tests

Two new tests: jumping to the convention-matching file, and the fallback when no file matches.

@sucicfilip
sucicfilip requested a review from a team as a code owner July 20, 2026 10:51
@sucicfilip sucicfilip closed this Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant