-
Notifications
You must be signed in to change notification settings - Fork 230
fix: resolve 4 bugs in termui #3671
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 |
|---|---|---|
|
|
@@ -182,7 +182,7 @@ function _pathsEqual(a: number[], b: number[]): boolean { | |
|
|
||
| function _valuesEqual(a: string[], b: string[]): boolean { | ||
| if (a.length !== b.length) return false; | ||
| const sortedA = [...a].sort(); | ||
| const sortedA = [...a].sort((a, b) => a - b); | ||
| const sortedB = [...b].sort(); | ||
|
Comment on lines
+185
to
186
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 | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== files =="
git ls-files | rg '(^|/)TreeSelect(\.ts|\.test\.ts|\.tsx)$|packages/ui/src/TreeSelect'
echo "== outline =="
if [ -f packages/ui/src/TreeSelect.ts ]; then
ast-grep outline packages/ui/src/TreeSelect.ts || true
fi
echo "== relevant lines =="
if [ -f packages/ui/src/TreeSelect.ts ]; then
sed -n '150,210p' packages/ui/src/TreeSelect.ts | cat -n
fi
echo "== tests with values =="
if [ -f packages/ui/src/TreeSelect.test.ts ]; then
rg -n -C 3 "TreeSelect|_valuesEqual|values=|setKey|handleKey|sort|s|a|10|2" packages/ui/src/TreeSelect.test.ts || true
fi
echo "== package script availability =="
ls -la packages/ui/package.json 2>/dev/null || trueRepository: Karanjot786/TermUI Length of output: 6604 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== all _valuesEqual usages =="
rg -n "_valuesEqual|selectedValues|selectedValues.set|selectedValues.has|selectedValues.add" packages/ui/src packages --glob '*.ts' --glob '*.tsx' || true
echo "== source around calls =="
sed -n '1,120p' packages/ui/src/TreeSelect.ts | cat -nRepository: Karanjot786/TermUI Length of output: 12579 🏁 Script executed: #!/bin/bash
set -euo pipefail
node - <<'JS'
function valuesEqualNumeric(a, b) {
const sortedA = [...a].sort((a, b) => a - b);
const sortedB = [...b].sort();
if (sortedA.length !== sortedB.length) return false;
for (let i = 0; i < sortedA.length; i++) if (sortedA[i] !== sortedB[i]) return false;
return true;
}
function valuesEqualSameComparator(a, b) {
const compare = (left, right) => {
const leftNumber = Number(left);
const rightNumber = Number(right);
if (Number.isFinite(leftNumber) && Number.isFinite(rightNumber)) return leftNumber - rightNumber;
return left.localeCompare(right);
};
const sortedA = [...a].sort(compare);
const sortedB = [...b].sort(compare);
if (sortedA.length !== sortedB.length) return false;
for (let i = 0; i < sortedA.length; i++) if (sortedA[i] !== sortedB[i]) return false;
return true;
}
for (const pairs of [
[['10','2'], ['2','10']],
[['a','b'], ['b','a']],
[['a','10'], ['10','a']]
]) {
console.log(JSON.stringify({ pairs, current: valuesEqualNumeric(...pairs), sameComparator: valuesEqualSameComparator(...pairs) }));
}
JSRepository: Karanjot786/TermUI Length of output: 369 Use one comparator for
🤖 Prompt for AI Agents |
||
| for (let i = 0; i < sortedA.length; i++) { | ||
| if (sortedA[i] !== sortedB[i]) return false; | ||
|
|
||
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
Fix the invalid
.catchcallback before merge.Line [383] does not parse because the callback parameter is missing. This blocks the TypeScript build. Pass the rejection value to
console.error; otherwise the error remains discarded.Proposed fix
📝 Committable suggestion
🧰 Tools
🪛 Biome (2.5.6)
[error] 383-383: Expected a parenthesis '(' but instead found '=>'.
(parse)
🤖 Prompt for AI Agents
Source: Linters/SAST tools