Repository navigation
fix: keep backtick-quoted column names with commas intact when toggling columns #3451
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
2ca2493
9393cb1
4e44358
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 |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| '@hyperdx/common-utils': patch | ||
| '@hyperdx/app': patch | ||
| --- | ||
|
|
||
| fix: keep backtick-quoted column names that contain a comma intact when toggling search columns or editing group by |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -134,12 +134,29 @@ export function splitAndTrimWithBracket(input: string): string[] { | |
| let squareCount: number = 0; | ||
| let inSingleQuote: boolean = false; | ||
| let inDoubleQuote: boolean = false; | ||
| let inBacktick: boolean = false; | ||
|
|
||
| const res: string[] = []; | ||
| let cur: string = ''; | ||
| for (let i = 0; i <= input.length; i++) { | ||
| const c = i === input.length ? ',' : input[i]; | ||
|
|
||
| if ( | ||
| c === '`' && | ||
| !inSingleQuote && | ||
| !inDoubleQuote && | ||
| !isQuoteEscapedByBackslash(input, i) | ||
| ) { | ||
| inBacktick = !inBacktick; | ||
| cur += c; | ||
| continue; | ||
| } | ||
|
|
||
| if (inBacktick) { | ||
| cur += c; | ||
| continue; | ||
| } | ||
|
|
||
| if (c === '"' && !inSingleQuote && !isQuoteEscapedByBackslash(input, i)) { | ||
| inDoubleQuote = !inDoubleQuote; | ||
| cur += c; | ||
|
|
@@ -178,6 +195,12 @@ export function splitAndTrimWithBracket(input: string): string[] { | |
| cur += c; | ||
| } | ||
| } | ||
| // An unclosed quote swallows the closing ','; keep its text so a half-typed | ||
| // name survives. Unclosed brackets still drop it, as parseToStartOfFunction expects. | ||
| if (inBacktick || inSingleQuote || inDoubleQuote) { | ||
|
Contributor
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. 🔵 minor — Unclosed-quote fallback also fires when brackets are unbalanced, which contradicts the comment and the PR description The fallback only checks the quote flags. Input with an unclosed bracket that also has an open quote, such as Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond |
||
| const rest = cur.slice(0, -1).trim(); | ||
| if (rest) res.push(rest); | ||
| } | ||
| return res; | ||
| } | ||
|
|
||
|
|
||
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.
🔵 minor — Keeping the text after an unclosed quote lets the columns editor absorb columns added after it
ColumnsPopoverrebuilds the draft withitems.join(', ')and then splits it again (packages/app/src/components/SearchResultsToolbar/ColumnsPopover.tsx:86,93,110). Take the draftTimestamp,aand addBody. The draft becomesTimestamp,a, Body, which splits back into['Timestamp', 'a, Body'].Bodynever shows up as its own row and stays in the options list, so each further click appends, Bodyagain. Dragging ``a `` aboveTimestamphas the same effect and merges the two into one item. Before this PR the dangling item was dropped instead. Two possible fixes: disable add and reorder while the last item has an open quote, or have the splitter tell callers which item is unterminated so the editor can block structural edits on it. Add a ColumnsPopover test that adds a column after an unclosed backtick.Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond