-
Notifications
You must be signed in to change notification settings - Fork 230
fix: resolve 4 bugs in termui #3653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -44,7 +44,7 @@ export function collectDeps(content: string): string[] { | |||||
| const deps = new Set<string>(); | ||||||
| let m: RegExpExecArray | null; | ||||||
| while ((m = re.exec(content)) !== null) deps.add(m[1]!); | ||||||
| return [...deps].sort(); | ||||||
| return [...deps].sort((a, b) => a - b); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== files =="
git ls-files | rg '(^|/)build-registry(\.test)?\.ts$' || true
echo "== build-registry.ts =="
if [ -f scripts/build-registry.ts ]; then
nl -ba scripts/build-registry.ts | sed -n '1,90p'
fi
echo "== related tests =="
if [ -f scripts/build-registry.test.ts ]; then
nl -ba scripts/build-registry.test.ts | sed -n '1,180p'
fi
echo "== tsconfig(s) =="
fd -a 'tsconfig.*\.json$' . -d 3 | sort | sed 's#^\./##' | while read -r f; do
echo "--- $f"
nl -ba "$f" | sed -n '1,140p'
done
echo "== TypeScript availability and arithmetic probe =="
if command -v tsc >/dev/null 2>&1; then
echo "tsc version:"
tsc --version
tmp="$(mktemp -d)"
cat > "$tmp/probe.ts" <<'TS'
const deps: string[] = ['apple', 'banana', 'apricot'];
deps.sort((a: string, b: string) => a - b);
TS
(tsc --noEmit --strict "$tmp/probe.ts" 2>&1 | sed -n '1,120p') || true
else
node - <<'JS'
const deps = ['apple', 'banana', 'apricot'];
const out = [...deps].sort((a, b) => a - b);
console.log(JSON.stringify(out));
JS
fiRepository: Karanjot786/TermUI Length of output: 289 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== build-registry.ts =="
if [ -f scripts/build-registry.ts ]; then
cat -n scripts/build-registry.ts | sed -n '1,90p'
fi
echo "== related tests =="
if [ -f scripts/build-registry.test.ts ]; then
cat -n scripts/build-registry.test.ts | sed -n '1,180p'
fi
echo "== tsconfig(s) =="
find . -maxdepth 3 -name 'tsconfig*.json' -print | sort | while read -r f; do
echo "--- $f"
cat -n "$f" | sed -n '1,160p'
done
echo "== TypeScript availability and arithmetic probe =="
if command -v tsc >/dev/null 2>&1; then
echo "tsc version:"
tsc --version
tmp="$(mktemp -d)"
cat > "$tmp/probe.ts" <<'TS'
const deps: string[] = ['apple', 'banana', 'apricot'];
deps.sort((a: string, b: string) => a - b);
TS
(tsc --noEmit --strict "$tmp/probe.ts" 2>&1 | sed -n '1,120p') || true
else
echo "tsc not available"
node - <<'JS'
const deps = ['apple', 'banana', 'apricot'];
const out = [...deps].sort((a, b) => a - b);
console.log(JSON.stringify(out));
JS
fiRepository: Karanjot786/TermUI Length of output: 34283 Use a string comparator for dependency specifiers.
- return [...deps].sort((a, b) => a - b);
+ return [...deps].sort((a, b) => a.localeCompare(b));📝 Committable suggestion
Suggested change
🤖 Prompt for AI AgentsSource: Coding guidelines |
||||||
| } | ||||||
|
|
||||||
| export function toSlug(name: string): string { | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
Validate the complete input before accepting a selection.
Number.isNaN(n)is equivalent to the previous check here becausenis already a number fromparseInt. It does not reject inputs with numeric prefixes. For example,2abcand2.5both parse as2, so the prompt can select the wrong option.Parse the complete input and require an integer index. Add regression tests for malformed and decimal input.
Proposed fix
🤖 Prompt for AI Agents