escape value on paste
I occassionally get "double quote chars are not consistent" formatting error. Can this plugin add support for auto-escaping quotes when pasting text into a CSV file? If that is out of scope for this extension then are there any that can be recommended? I haven't found one yet.
I am unaware of any extension that would do this, but it sounds like an interesting feature! Can you please add an example of an unescaped text fragment and then how would the escaped version look like?
Yes. Thank you.
Initial CSV file contents:
id,story
1,"Geolocation ""foreground"" support"
Edit scenarios:
- Paste
2,Geolocation "background" support. - Type
2,manually and then pasteGeolocation "background" support.
Current result:
id,story
1,"Geolocation ""foreground"" support"
2,Geolocation "background" support
Desired result:
id,story
1,"Geolocation ""foreground"" support"
2,"Geolocation ""background"" support"
An alternative solution might be to detect whenever pasting inside existing quotation marks and then escape any quotation marks inside the text being pasted.
IMO this is doable there is already a concept of "simple" dialect that doesn't treat double quotes in any special way. So the logic could be to try to parse the fragment as standard csv, if this fails try to parse as "simple" - if this succeeds - reencode and replace the new fragment with standard dialect with escaped double quotes. There is also a question of how intrusive this replacement would be, probably needs some sort of dialog to confirm such automatic alteration of the copied data.
I got confused for a moment and though VS Code had some built-in support for CSV. 🤪
However, when I created a feature request there I did have some more clarity on how I think this should perhaps work and I outlined three simple scenarios (https://github.com/microsoft/vscode/issues/262971):
here's one scenario:
Given `this is "cool"` on my clipboard When I paste it into an empty CSV field Then the inserted text is `"this is ""cool"""`here's another scenario:
Given `this is "cool"` on my clipboard When I paste it into a non-empty CSV field that is already double-quoted Then the inserted text is `this is ""cool""`one more scenario:
Given `this is "cool"` on my clipboard When I paste it into a non-empty CSV field that is NOT already double-quoted Then the inserted text is `this is ""cool""` and the field value is wrapped in double-quotes