Skip to content

Commit fb95b38

Browse files
committed
Sort string completions alphabetically
1 parent 114ba13 commit fb95b38

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/app/components/generator/McdocRenderer.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,11 @@ function StringHead({ type, optional, excludeStrings, node, ctx }: Props<StringT
180180
}, [value, onChangeValue])
181181

182182
const completions = useMemo(() => {
183-
return getValues(type, { ...ctx, offset: node?.range.start ?? 0 })
183+
const values = getValues(type, { ...ctx, offset: node?.range.start ?? 0 })
184184
.filter(c => c.kind === 'string' && c.value !== 'THIS')
185185
.filter(c => !excludeStrings?.includes(c.value))
186+
values.sort((a, b) => a.value.localeCompare(b.value))
187+
return values
186188
}, [type, excludeStrings, node, ctx])
187189

188190
const datalistId = `mcdoc_completions_${hexId()}`

0 commit comments

Comments
 (0)