fix: formatting

This commit is contained in:
Davor Racić 2026-02-03 10:27:50 +01:00
parent 3e2da9c728
commit 1ff3323c87
2 changed files with 27 additions and 53 deletions

View File

@ -268,12 +268,12 @@ async function autocompleteMultiselect(options) {
const hasPlaceholder = userInput === '' && placeholder !== undefined; const hasPlaceholder = userInput === '' && placeholder !== undefined;
// Show placeholder or user input with cursor // Show placeholder or user input with cursor
const searchDisplay = this.isNavigating || hasPlaceholder const searchDisplay =
? color.dim(hasPlaceholder ? placeholder : userInput) this.isNavigating || hasPlaceholder ? color.dim(hasPlaceholder ? placeholder : userInput) : this.userInputWithCursor;
: this.userInputWithCursor;
const allOptions = this.options; const allOptions = this.options;
const matchCount = this.filteredOptions.length === allOptions.length const matchCount =
this.filteredOptions.length === allOptions.length
? '' ? ''
: color.dim(` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? '' : 'es'})`); : color.dim(` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? '' : 'es'})`);
@ -283,9 +283,7 @@ async function autocompleteMultiselect(options) {
const label = opt.label ?? String(opt.value ?? ''); const label = opt.label ?? String(opt.value ?? '');
const hintText = opt.hint && opt.value === this.focusedValue ? color.dim(` (${opt.hint})`) : ''; const hintText = opt.hint && opt.value === this.focusedValue ? color.dim(` (${opt.hint})`) : '';
const checkbox = isSelected ? color.green(clack.S_CHECKBOX_SELECTED) : color.dim(clack.S_CHECKBOX_INACTIVE); const checkbox = isSelected ? color.green(clack.S_CHECKBOX_SELECTED) : color.dim(clack.S_CHECKBOX_INACTIVE);
return isHighlighted return isHighlighted ? `${checkbox} ${label}${hintText}` : `${checkbox} ${color.dim(label)}`;
? `${checkbox} ${label}${hintText}`
: `${checkbox} ${color.dim(label)}`;
}; };
switch (this.state) { switch (this.state) {
@ -299,19 +297,11 @@ async function autocompleteMultiselect(options) {
default: { default: {
// Always show "SPACE:" regardless of isNavigating state // Always show "SPACE:" regardless of isNavigating state
const hints = [ const hints = [`${color.dim('↑/↓')} to navigate`, `${color.dim('TAB/SPACE:')} select`, `${color.dim('ENTER:')} confirm`];
`${color.dim('↑/↓')} to navigate`,
`${color.dim('TAB/SPACE:')} select`,
`${color.dim('ENTER:')} confirm`,
];
const noMatchesLine = this.filteredOptions.length === 0 && userInput const noMatchesLine = this.filteredOptions.length === 0 && userInput ? [`${bar} ${color.yellow('No matches found')}`] : [];
? [`${bar} ${color.yellow('No matches found')}`]
: [];
const errorLine = this.state === 'error' const errorLine = this.state === 'error' ? [`${bar} ${color.yellow(this.error)}`] : [];
? [`${bar} ${color.yellow(this.error)}`]
: [];
const headerLines = [ const headerLines = [
...`${title}${bar}`.split('\n'), ...`${title}${bar}`.split('\n'),
@ -320,10 +310,7 @@ async function autocompleteMultiselect(options) {
...errorLine, ...errorLine,
]; ];
const footerLines = [ const footerLines = [`${bar} ${color.dim(hints.join(' • '))}`, `${barEnd}`];
`${bar} ${color.dim(hints.join(' • '))}`,
`${barEnd}`,
];
const optionLines = clack.limitOptions({ const optionLines = clack.limitOptions({
cursor: this.cursor, cursor: this.cursor,
@ -334,11 +321,7 @@ async function autocompleteMultiselect(options) {
rowPadding: headerLines.length + footerLines.length, rowPadding: headerLines.length + footerLines.length,
}); });
return [ return [...headerLines, ...optionLines.map((line) => `${bar} ${line}`), ...footerLines].join('\n');
...headerLines,
...optionLines.map((line) => `${bar} ${line}`),
...footerLines,
].join('\n');
} }
} }
}, },

View File

@ -402,9 +402,7 @@ class UI {
}); });
// Sort initialValues to match display order // Sort initialValues to match display order
const sortedInitialValues = sortedTools const sortedInitialValues = sortedTools.filter((ide) => configuredIdes.includes(ide.value)).map((ide) => ide.value);
.filter((ide) => configuredIdes.includes(ide.value))
.map((ide) => ide.value);
const upgradeSelected = await prompts.autocompleteMultiselect({ const upgradeSelected = await prompts.autocompleteMultiselect({
message: 'Select tools to install:', message: 'Select tools to install:',
@ -488,9 +486,7 @@ class UI {
// - User selected nothing from recommended (so they can pick from everything) // - User selected nothing from recommended (so they can pick from everything)
// Otherwise, show only "other" tools as additional options // Otherwise, show only "other" tools as additional options
const showAllTools = wantsBrowseAll || filteredRecommended.length === 0; const showAllTools = wantsBrowseAll || filteredRecommended.length === 0;
const toolsToShow = showAllTools const toolsToShow = showAllTools ? [...preferredIdes, ...otherIdes] : otherIdes;
? [...preferredIdes, ...otherIdes]
: otherIdes;
if (toolsToShow.length > 0) { if (toolsToShow.length > 0) {
const allToolOptions = toolsToShow.map((ide) => { const allToolOptions = toolsToShow.map((ide) => {
@ -506,10 +502,7 @@ class UI {
}); });
// Pre-select: previously configured tools + any recommended tools already selected // Pre-select: previously configured tools + any recommended tools already selected
const initialValues = [ const initialValues = [...configuredIdes, ...filteredRecommended].filter((v, i, arr) => arr.indexOf(v) === i); // dedupe
...configuredIdes,
...filteredRecommended,
].filter((v, i, arr) => arr.indexOf(v) === i); // dedupe
// Use "additional" only if user already selected some recommended tools // Use "additional" only if user already selected some recommended tools
const isAdditional = !wantsBrowseAll && filteredRecommended.length > 0; const isAdditional = !wantsBrowseAll && filteredRecommended.length > 0;
@ -530,9 +523,7 @@ class UI {
// Combine selections: // Combine selections:
// - If "Browse All" was used, the second prompt contains ALL selections // - If "Browse All" was used, the second prompt contains ALL selections
// - Otherwise, combine recommended + additional // - Otherwise, combine recommended + additional
const allSelectedIdes = wantsBrowseAll const allSelectedIdes = wantsBrowseAll ? selectedAdditionalOrAll : [...filteredRecommended, ...selectedAdditionalOrAll];
? selectedAdditionalOrAll
: [...filteredRecommended, ...selectedAdditionalOrAll];
// ───────────────────────────────────────────────────────────────────────────── // ─────────────────────────────────────────────────────────────────────────────
// STEP 3: Confirm if no tools selected // STEP 3: Confirm if no tools selected