From 28dbc5c51eeb167f5e28308d77dbc697f19bdb10 Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Thu, 5 Jun 2025 18:55:54 +0200 Subject: [PATCH] [ty] Fix completion order in playground (#18480) --- playground/ty/src/Editor/Editor.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/playground/ty/src/Editor/Editor.tsx b/playground/ty/src/Editor/Editor.tsx index a25e3b4ddb..1fb7427df7 100644 --- a/playground/ty/src/Editor/Editor.tsx +++ b/playground/ty/src/Editor/Editor.tsx @@ -202,9 +202,13 @@ class PlaygroundServer new TyPosition(position.lineNumber, position.column), ); + // If completions is 100, this gives us "99" which has a length of two + const digitsLength = String(completions.length - 1).length; + return { - suggestions: completions.map((completion) => ({ + suggestions: completions.map((completion, i) => ({ label: completion.label, + sortText: String(i).padStart(digitsLength, "0"), kind: CompletionItemKind.Variable, insertText: completion.label, // TODO(micha): It's unclear why this field is required for monaco but not VS Code. @@ -491,7 +495,7 @@ class PlaygroundServer this.typeDefinitionProviderDisposable.dispose(); this.inlayHintsDisposable.dispose(); this.formatDisposable.dispose(); - this.editorOpenerDisposable.dispose(); + this.completionDisposable.dispose(); } }