-
Notifications
You must be signed in to change notification settings - Fork 232
fix: resolve 4 bugs in termui #3503
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
base: main
Are you sure you want to change the base?
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); | ||
|
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 | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
file="packages/ui/src/TreeSelect.ts"
# Confirm both arrays use the same comparator.
rg -n -C 2 'sortedA|sortedB|sort\(' "$file"
# Locate the repository's declared type-check command.
rg -n '"(typecheck|type-check|build)"' package.json packages/ui/package.json 2>/dev/null || trueRepository: Karanjot786/TermUI Length of output: 740 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
file="packages/ui/src/TreeSelect.ts"
sed -n '160,195p' "$file"
echo '---'
sed -n '1,60p' "$file"
echo '---'
node - <<'JS'
const a = ["2", "10"];
const b = ["10", "2"];
const sortedA = [...a].sort((x, y) => x - y);
const sortedB = [...b].sort();
console.log(JSON.stringify({a, b, sortedA, sortedB}));
console.log(sortedA.every((v, i) => v === sortedB[i]));
JSRepository: Karanjot786/TermUI Length of output: 3502 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
node - <<'TS'
// Read-only behavioral probe for JavaScript subtraction order on strings.
// This does not execute repository code; it only exercises runtime semantics.
const cases = [
[
["2", "10"],
["10", "2"]
],
[
["10", "2"],
["2", "10"]
],
[
["1", "20", "3"],
["3", "20", "1"],
],
];
for (const [a, b] of cases) {
const sortedA = [...a].sort((a, b) => a - b);
const sortedB = [...b].sort();
console.log(JSON.stringify({
a,
b,
sortedA,
sortedB,
equal: sortedA.every((v, i) => v === sortedB[i])
}));
}
TSRepository: Karanjot786/TermUI Length of output: 436 Use a shared numeric comparator for both value arrays.
🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| const sortedB = [...b].sort(); | ||
| 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 arrow function syntax.
The arrow function
( => console.error())is missing its parameter list. This is a syntax error and will fail to parse.Biome confirms this: "Expected a parenthesis '(' but instead found '=>'."
Also pass the rejection reason to
console.error, otherwise the log gives no information about the failure.🐛 Proposed fix
📝 Committable suggestion
🧰 Tools
🪛 Biome (2.5.5)
[error] 383-383: Expected a parenthesis '(' but instead found '=>'.
(parse)
🤖 Prompt for AI Agents
Source: Linters/SAST tools