-
Notifications
You must be signed in to change notification settings - Fork 251
fix: resolve remaining PR 496 review issues #501
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 | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -82,7 +82,9 @@ function isNumericValue(value: string): boolean { | |||||||||||||||||||||||
| const trimmed = value.trim(); | ||||||||||||||||||||||||
| if (trimmed === '') return false; | ||||||||||||||||||||||||
| // Match: optional currency/sign prefix, digits with optional commas, optional decimal, optional suffix | ||||||||||||||||||||||||
| return /^[($\-]*[\d,]+(\.\d+)?[%)]*$/.test(trimmed); | ||||||||||||||||||||||||
| return /^(?:-?\$?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?%?|\(\$?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?\)%?)$/.test( | ||||||||||||||||||||||||
| trimmed | ||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||
|
|
@@ -149,8 +151,8 @@ function highlightMatches(text: string, query: string, accentColor: string): Rea | |||||||||||||||||||||||
| // Use running character offset as key to guarantee uniqueness across | ||||||||||||||||||||||||
| // identical substrings appearing at different positions. | ||||||||||||||||||||||||
| let offset = 0; | ||||||||||||||||||||||||
| return parts.map((part) => { | ||||||||||||||||||||||||
| const key = offset; | ||||||||||||||||||||||||
| return parts.map((part, index) => { | ||||||||||||||||||||||||
| const key = `${offset}-${index}`; | ||||||||||||||||||||||||
|
Comment on lines
151
to
+155
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. Stale comment + overly complex key The comment at line 151–152 still says the offset alone "guarantee[s] uniqueness", but the whole reason this bug existed is that Since
Suggested change
The compound |
||||||||||||||||||||||||
| offset += part.length; | ||||||||||||||||||||||||
| return regex.test(part) ? ( | ||||||||||||||||||||||||
| <mark | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
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.
🧩 Analysis chain
🏁 Script executed:
cat -n src/renderer/components/CsvTableRenderer.tsx | head -200Repository: RunMaestro/Maestro
Length of output: 6628
🏁 Script executed:
Repository: RunMaestro/Maestro
Length of output: 859
🏁 Script executed:
Repository: RunMaestro/Maestro
Length of output: 545
🏁 Script executed:
Repository: RunMaestro/Maestro
Length of output: 194
Parenthesized negatives are detected but sorted with the wrong sign
Line 85 now classifies values like
(123)and($45.67)as numeric, butcompareValues(lines 130–131) strips()without converting to negative, so these values sort as positive numbers.Proposed fix
function isNumericValue(value: string): boolean { const trimmed = value.trim(); if (trimmed === '') return false; // Match: optional currency/sign prefix, digits with optional commas, optional decimal, optional suffix return /^(?:-?\$?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?%?|\(\$?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?\)%?)$/.test( trimmed ); } + +function parseNumericValue(value: string): number | null { + const trimmed = value.trim(); + if (!isNumericValue(trimmed)) return null; + + const isParenNegative = /^\(.*\)$/.test(trimmed); + const normalized = trimmed.replace(/[,$%()]/g, ''); + const num = Number(normalized); + if (Number.isNaN(num)) return null; + + return isParenNegative ? -num : num; +} function compareValues(a: string, b: string, direction: SortDirection): number { const aVal = a.trim(); const bVal = b.trim(); @@ - const aNum = parseFloat(aVal.replace(/[,$%()]/g, '')); - const bNum = parseFloat(bVal.replace(/[,$%()]/g, '')); - - if (!isNaN(aNum) && !isNaN(bNum)) { + const aNum = parseNumericValue(aVal); + const bNum = parseNumericValue(bVal); + if (aNum !== null && bNum !== null) { return direction === 'asc' ? aNum - bNum : bNum - aNum; }📝 Committable suggestion
🤖 Prompt for AI Agents