Preserve literal quotes in view-mode paste#437
Conversation
Move paste-specific quote handling into a dedicated parser so simple quoted fields no longer lose quote characters during paste. Keep legacy handling for quoted numeric single values while covering the new behavior with reducer, parser, and UI tests. Made-with: Cursor
|
Thank you for your contribution! Does this match the behaviour on Google Sheets? |
Thanks! Not completely. The main behavior I aligned with Google Sheets here is that simple quoted text fields like One intentional compatibility exception in this PR is quoted numeric single values like |
|
Yes, I prefer full parity as much as possible - thank you so much!!! |
|
@iddan I think preserving quoted numeric single values like That follow-up removes the quoted-numeric compatibility exception so single-cell and multi-cell quoted fields behave consistently and match Google Sheets more closely. |
Thanks for maintaining
react-spreadsheetand for taking a look at this bug fix.Summary
"aa""123"src/paste.tssrc/matrix.tsuntouched to avoid broad parser behavior changesWhy
In the current behavior, view-mode paste can lose user data when a simple quoted field is pasted.
For example:
"aa"\taturns the first cell intoaa"aa"loses the literal quotes in that columnThis is a data-loss issue in the paste path, not a generic
Matrix.split()issue. To keep the scope conservative, this change only adjusts the clipboard interpretation used by paste.Behavior changes
Before:
"Value"pasted as a single cell becameValue"123"pasted as a single cell became123"aa"\talost quotes in the first cell and becameaa,a"Value\t1"\tValue2was interpreted by the existing parser and unquoted the first fieldAfter:
"Value"pasted as a single cell stays"Value""123"pasted as a single cell still becomes123to preserve legacy compatibility"aa"\takeeps the first cell as"aa"and the second cell asa"Value\t1"\tValue2still unquotes the first field because the quotes are protecting a tab separatorScope
src/paste.ts,src/reducer.ts,src/paste.test.ts,src/reducer.test.ts,src/Spreadsheet.test.tsxMatrix.split()changesMatrix.split()a complete TSV/CSV parser in this PRCompatibility notes
"123"