Skip to content

Commit ae056a7

Browse files
committed
cli: Tweak display layout for suggestion menu
1 parent de46526 commit ae056a7

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

cli/src/components/suggestion-menu.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,8 @@ export const SuggestionMenu = ({
6767
),
6868
)
6969

70-
// Find the longest description to determine if we can use same-line layout
71-
const maxDescriptionLength = Math.max(
72-
...visibleItems.map((item) => item.description.length),
73-
)
74-
75-
// Check if all items can fit on same line with aligned descriptions
76-
const minWidthForSameLine = maxLabelLength + 2 + maxDescriptionLength
77-
const useSameLine = menuWidth >= minWidthForSameLine
70+
// Account for button padding (paddingLeft + paddingRight = 2)
71+
const availableWidth = menuWidth - 2
7872

7973
const renderSuggestionItem = (item: SuggestionItem, idx: number) => {
8074
const absoluteIndex = start + idx
@@ -92,7 +86,10 @@ export const SuggestionMenu = ({
9286
setHasHoveredSinceOpen(true)
9387
}
9488

95-
if (useSameLine) {
89+
// Check per-item if description fits on the same line (using maxLabelLength for alignment padding)
90+
const itemFitsOnSameLine = availableWidth >= maxLabelLength + 2 + item.description.length
91+
92+
if (itemFitsOnSameLine) {
9693
// Calculate padding to align descriptions
9794
const paddingLength = maxLabelLength - labelLength
9895
const padding = ' '.repeat(paddingLength)

0 commit comments

Comments
 (0)