-
Notifications
You must be signed in to change notification settings - Fork 233
fix: resolve 4 bugs in termui #3657
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -104,7 +104,7 @@ class CustomMultiProgress extends (MultiProgressClass as any) { | |||||
| const value = Math.max(0, Math.min(1, item.value)); | ||||||
| const filled = Math.round(barWidth * value); | ||||||
|
|
||||||
| const pct = Math.round(value * 100); | ||||||
| const pct = Math.round(value * 100 + Number.EPSILON); | ||||||
|
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: #!/usr/bin/env bash
set -euo pipefail
node <<'NODE'
const value = 0.145;
const current = Math.round(value * 100 + Number.EPSILON);
const corrected = Math.round((value + Number.EPSILON) * 100);
if (current !== 14 || corrected !== 15) {
throw new Error(`Unexpected results: ${current}, ${corrected}`);
}
NODERepository: Karanjot786/TermUI Length of output: 156 🌐 Web query:
💡 Result: The Number.EPSILON property in JavaScript represents the difference between 1 and the smallest floating-point number greater than 1 [1][2]. Its value is 2^-52, which is approximately 2.220446049250313e-16 [1][3]. This property is a static data property of the Number object and cannot be changed, as its attributes are [[Writable]]: false, [[Enumerable]]: false, and [[Configurable]]: false [4][5]. It is primarily used to handle floating-point arithmetic inaccuracies when comparing numbers that are close in value, as standard equality operators (===) can be unreliable for floating-point calculations [2]. Citations:
🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
node - <<'NODE'
const cases = [
{ value: 0.145, label: '0.145' },
{ value: Number.EPSILON / 100, label: 'Number.EPSILON/100' },
{ value: 0.005, label: '0.005' },
{ value: 0.999999999999999, label: 'near 1' },
];
for (const { value, label } of cases) {
const current = Math.round(value * 100 + Number.EPSILON);
const corrected = Math.round((value + Number.EPSILON) * 100);
console.log(label.padEnd(22), 'current:', current, 'corrected:', corrected, 'same:', current === corrected, 'value:', value, '0.145*100:', 0.145 * 100, 'eps:', Number.EPSILON);
}
NODERepository: Karanjot786/TermUI Length of output: 703 Add
- const pct = Math.round(value * 100 + Number.EPSILON);
+ const pct = Math.round((value + Number.EPSILON) * 100);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| const percentStr = ` ${pct}% `; | ||||||
| const showPct = barWidth >= percentStr.length; | ||||||
| const labelStart = showPct ? Math.floor((barWidth - percentStr.length) / 2) : -1; | ||||||
|
|
||||||
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: 197
🏁 Script executed:
Repository: Karanjot786/TermUI
Length of output: 3709
Reject out-of-range numeric entities before decoding.
The current checks allow decimal values such as
𚶰, which exceeds the Unicode code-point limit and throws inString.fromCodePoint. Reject non-integer code points and values above0x10ffffbefore decoding.🤖 Prompt for AI Agents