From 89961520324acecc60d7d4e9cab8a57983607033 Mon Sep 17 00:00:00 2001 From: Ali Hammoud Date: Wed, 26 Nov 2025 18:32:06 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20docs=20command=20crashes?= =?UTF-8?q?=20when=20select=20menu=20options=20text=20is=20longer=20than?= =?UTF-8?q?=20100=20chars?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/docs/baseline.ts | 8 +++----- src/commands/docs/mdn.ts | 4 ++-- src/commands/docs/npm.ts | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/commands/docs/baseline.ts b/src/commands/docs/baseline.ts index 79d6542..f1dc848 100644 --- a/src/commands/docs/baseline.ts +++ b/src/commands/docs/baseline.ts @@ -11,6 +11,7 @@ import { features as data } from 'web-features'; import { fuzzySearch } from '../../util/fuzzy-search.js'; import type { ProviderConfig } from './types.js'; import { createBaseConfig, getBaselineFeatures } from './utils.js'; +import { clampText } from '../../util/text.js'; export type FeatureData = { name: string; @@ -72,11 +73,8 @@ export const baselineProvider: ProviderConfig = { .setMaxValues(1) .addOptions( ...data.map((feature) => ({ - label: feature.name.length > 100 ? `${feature.name.slice(0, 97)}...` : feature.name, - description: - feature.description.length > 100 - ? `${feature.description.slice(0, 97)}...` - : feature.description, + label: clampText(feature.name, 100), + description: clampText(feature.description, 100), value: feature.key, })) ) diff --git a/src/commands/docs/mdn.ts b/src/commands/docs/mdn.ts index a759d3c..d58b77a 100644 --- a/src/commands/docs/mdn.ts +++ b/src/commands/docs/mdn.ts @@ -56,8 +56,8 @@ export const mdnProvider: ProviderConfig = { .setMaxValues(Math.min(5, data.size)) .addOptions( ...data.map((doc) => ({ - label: doc.title.length > 100 ? `${doc.title.slice(0, 97)}...` : doc.title, - description: doc.summary.length > 100 ? `${doc.summary.slice(0, 97)}...` : doc.summary, + label: clampText(doc.title, 100), + description: clampText(doc.summary, 100), value: doc.slug, })) ) diff --git a/src/commands/docs/npm.ts b/src/commands/docs/npm.ts index 1461b9c..62c1dfb 100644 --- a/src/commands/docs/npm.ts +++ b/src/commands/docs/npm.ts @@ -64,7 +64,7 @@ export const npmProvider: ProviderConfig = { ...data.map((pkg) => new StringSelectMenuOptionBuilder() .setLabel(pkg.name) - .setDescription(pkg.description) + .setDescription(clampText(pkg.description, 100)) .setValue(pkg.name) ) )