-
Notifications
You must be signed in to change notification settings - Fork 232
fix: resolve 2 bugs #3373
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?
fix: resolve 2 bugs #3373
Changes from 1 commit
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,8 +182,8 @@ 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 sortedB = [...b].sort(); | ||
| const sortedA = [...a].sort((a, b) => a - b); | ||
| const sortedB = [...b].sort((a, b) => a - b); | ||
|
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 | 🔴 Critical | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== files =="
git ls-files 'packages/ui/src/TreeSelect.ts' 'scripts/build-registry.ts' 'tsconfig*.json' 2>/dev/null || true
echo
echo "== package type settings =="
for f in $(git ls-files 'tsconfig*.json' 'packages/**/tsconfig*.json' 'scripts/**/tsconfig*.json' 2>/dev/null | head -50); do
echo "--- $f"
sed -n '1,220p' "$f" | rg -n '"strict"|"moduleResolution"|"noImplicitAny"|"target"|"lib"|compilerOptions' || true
done
echo
echo "== TreeSelect relevant lines =="
sed -n '1,240p' packages/ui/src/TreeSelect.ts 2>/dev/null || true
echo
echo "== build-registry relevant lines =="
sed -n '1,120p' scripts/build-registry.ts 2>/dev/null || true
echo
echo "== occurrences =="
rg -n "sort\\(\\(a, b\\) => a - b\\)|sort\\(\\(a, b\\) =>" -S packages/ui/src scripts/build-registry.ts packages 2>/dev/null || true
echo
echo "== TypeScript availability/parser probe =="
node -e "const fs=require('node:fs'); for (const p of ['packages/ui/src/TreeSelect.ts','scripts/build-registry.ts']) console.log(p, 'exists', fs.existsSync(p));"
if command -v npx >/dev/null 2>&1; then
echo "npx available"
npx tsc --version 2>/dev/null || true
else
echo "npx unavailable"
fi
python3 - <<'PY'
import subprocess, textwrap, json, re, os
files = ['packages/ui/src/TreeSelect.ts','scripts/build-registry.ts']
for f in files:
print(f"--- {f}")
data = open(f,'r').read()
for i,line in enumerate(data.splitlines(),1):
if 'sort((a, b) => a - b)' in line:
print(f"{i}:{line}")
PYRepository: Karanjot786/TermUI Length of output: 15092 🏁 Script executed: #!/bin/bash
set -euo pipefail
node - <<'JS'
const values = {
zero: ['0', '0'],
numerics: ['1', '10', '2'],
packages: ['`@termuijs/core`', '`@termuijs/widgets`'],
mixed_nonnumeric: ['abc', '1'],
};
for (const [name, arr] of Object.entries(values)) {
const withSubtract = arr.slice().sort((a, b) => a - b);
const withLocaleCompare = arr.slice().sort((a, b) => a.localeCompare(b));
console.log(name, 'input', JSON.stringify(arr), 'subtract', JSON.stringify(withSubtract), 'localeCompare', JSON.stringify(withLocaleCompare));
}
JS
TS_VERSION=$(npx tsc --version 2>/dev/null | awk '{print $2}' || true)
tmpdir=${PWD}/tmp-ts-string-subtract-probe
rm -rf "$tmpdir"
mkdir -p "$tmpdir"
cat > "$tmpdir/comparators.ts" <<'TS'
function subtract(a: string, b: string): number { return a - b; }
subtract('0', '0');
subtract('1', '10');
function localeCompare(a: string, b: string): number { return a.localeCompare(b); }
localeCompare('0', '0');
localeCompare('1', '10');
TS
cat > "$tmpdir/tsconfig.json" <<'JSON'
{
"compilerOptions": {
"target": "ES2022",
"moduleResolution": "bundler",
"lib": ["ES2022"],
"strict": true,
"noEmit": true
},
"files": ["comparators.ts"]
}
JSON
cd "$tmpdir"
timeout 60 npx tsc --showConfig 2>/dev/null | sed -n '1,120p' || true
echo "--- tsc output -----------------------"
timeout 60 npx tsc 2>&1 | sed -n '1,200p' || true
rm -rf "$tmpdir"Repository: Karanjot786/TermUI Length of output: 621 🏁 Script executed: #!/bin/bash
set -euo pipefail
node - <<'JS'
const values = {
zero: ['0', '0'],
numerics: ['1', '10', '2'],
packages: ['`@termuijs/core`', '`@termuijs/widgets`'],
mixed_nonnumeric: ['abc', '1'],
};
for (const [name, arr] of Object.entries(values)) {
const withSubtract = arr.slice().sort((a, b) => a - b);
const withLocaleCompare = arr.slice().sort((a, b) => a.localeCompare(b));
console.log(name, 'input', JSON.stringify(arr), 'subtract', JSON.stringify(withSubtract), 'localeCompare', JSON.stringify(withLocaleCompare));
}
JS
TS_VERSION=$(npx tsc --version 2>/dev/null | awk '{print $2}' || true)
tmpdir=${PWD}/tmp-ts-string-subtract-probe
rm -rf "$tmpdir"
mkdir -p "$tmpdir"
cat >("$tmpdir/comparators.ts") <<'TS'
function subtract(a: string, b: string): number { return a - b; }
subtract('0', '0');
subtract('1', '10');
function localeCompare(a: string, b: string): number { return a.localeCompare(b); }
localeCompare('0', '0');
localeCompare('1', '10');
TS
cat >"$tmpdir/tsconfig.json" <<'JSON'
{
"compilerOptions": {
"target": "ES2022",
"moduleResolution": "bundler",
"lib": ["ES2022"],
"strict": true,
"noEmit": true
},
"files": ["comparators.ts"]
}
JSON
cd "$tmpdir"
timeout 60 npx tsc --showConfig 2>/dev/null | sed -n '1,120p' || true
echo "--- tsc output -----------------------"
timeout 60 npx tsc 2>&1 | sed -n '1,200p' || true
rm -rf "$tmpdir"Repository: Karanjot786/TermUI Length of output: 688 Use string comparators instead of subtraction. Both comparators operate on string values, and subtraction produces numeric ordering instead of the intended string order for nonnumeric values such as 🧰 Tools🪛 GitHub Actions: CI / 0_build-and-test.txt[error] 185-186: TypeScript declaration build failed: arithmetic operands on lines 185-186 are not typed as any, number, bigint, or an enum (TS2362, TS2363). The ' 🪛 GitHub Actions: CI / build-and-test[error] 185-186: TypeScript declaration build failed: arithmetic operands on lines 185-186 are not typed as any, number, bigint, or an enum type (TS2362/TS2363). The 📍 Affects 2 files
🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| 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.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: Karanjot786/TermUI
Length of output: 156
🏁 Script executed:
Repository: Karanjot786/TermUI
Length of output: 2185
🏁 Script executed:
Repository: Karanjot786/TermUI
Length of output: 3268
Validate the Unicode range and entity length before replacing the entity.
Number.isFinitedoes not validate a Unicode code point. Inputs such as�or�can pass this check and makeString.fromCodePointthrowRangeError. Reject values outside0..0x10FFFFand reject entities longer than eight digits so the decoder does not decode a truncated prefix as a different code point.🤖 Prompt for AI Agents