fix(datagrid): keep pasted rows aligned when a cell value contains a comma#1436
Merged
Conversation
93165f6 to
01ae0ae
Compare
01ae0ae to
57fc132
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Copy a grid row with Cmd+Shift+C, paste it back, and the values land in the wrong columns when a cell contains a comma. Reported with a
last_user_agentvalue:Pasting produced:
Root cause
Cmd+Shift+C copies the row as TSV, but the paste path (
RowOperationsManager.pasteRowsFromClipboard) ignored the typed pasteboard data and re-guessed the format from plain text.detectParsertallied lines containing a tab vs a comma; a single row whose value holds a comma scoredtabLines == commaLines == 1, thetabCount > commaCounttie failed, and it fell back to the CSV parser. CSV ignores the tab separators and split the row on the first comma inside(KHTML, like Gecko), so one fragment landed intokenand the rest became NULL.The copy path already labels the clipboard with a private
com.TablePro.gridRowstype, but it only carried the flag"1"and the paste path never read it.Fix
Use the
NSPasteboardrepresentations the copy already produces instead of guessing:com.TablePro.gridRowsnow carries the JSON-encoded[[PluginCellValue]]. Paste decodes it first, so internal copy/paste is lossless: commas, embedded tabs/newlines, a realNULLvs the literal string"NULL", and binary all round-trip.detectParserrewritten for the genuine plain-text fallback (spreadsheets, the SQL editor, other apps): a tab anywhere means TSV (tab is the native tabular-clipboard delimiter for TablePro, Excel, and Numbers); CSV only when commas appear without tabs. This alone fixes external TSV-with-commas.The
writeRowssignature change and both test mocks are in the same commit.Tests
"NULL", and binary (ClipboardServiceTests)."NULL"distinction, structured-wins-over-text, anddetectParsercases (RowOperationsManagerPasteTests).Notes
No new user-facing strings, shortcuts, or settings, so no docs change.
docs/features/keyboard-shortcuts.mdxalready documents "Paste TSV as new rows"; this makes it hold for values containing commas.