Skip to content

[ty] Fix completion order in playground#18480

Merged
MichaReiser merged 1 commit intomainfrom
micha/fix-completion-order
Jun 5, 2025
Merged

[ty] Fix completion order in playground#18480
MichaReiser merged 1 commit intomainfrom
micha/fix-completion-order

Conversation

@MichaReiser
Copy link
Member

@MichaReiser MichaReiser commented Jun 5, 2025

Summary

By default, Monaco sorts the completion items by the label but we want to preserve the order
returned by the completions functions. Ideally, we could just disable sorting but I couldn't find a way to do this.

This PR sets the sortText which monaco uses for sorting. It's a bit awkward because it's a string (which gets compared in alphabetic ordering)
But the basic idea is that we use the padded index as sort key.

Test Plan

Screen.Recording.2025-06-05.at.18.28.01.mov

@MichaReiser MichaReiser added playground A playground-specific issue ty Multi-file analysis & type inference labels Jun 5, 2025
@MichaReiser MichaReiser requested a review from BurntSushi June 5, 2025 16:27
this.inlayHintsDisposable.dispose();
this.formatDisposable.dispose();
this.editorOpenerDisposable.dispose();
this.completionDisposable.dispose();
Copy link
Member Author

Choose a reason for hiding this comment

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

That was a copy paste error of mine

Copy link
Member

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

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

Love it.

@MichaReiser MichaReiser merged commit 28dbc5c into main Jun 5, 2025
34 checks passed
@MichaReiser MichaReiser deleted the micha/fix-completion-order branch June 5, 2025 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

playground A playground-specific issue ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants