atom / toggle-quotes

An Atom package to toggle between single and double quotes
MIT License
77 stars 36 forks source link

Toggle quotes doesn't work on invalid single-quoted string JSON values #16

Open mnquintana opened 9 years ago

mnquintana commented 9 years ago

Use case: I started with a plain ol' JS object, which I then wanted to convert to a separate JSON file. My JS object used single quoted strings as values. When I copy it to the JSON file, I want to use toggle-quotes to convert all of these invalid single-quoted strings to valid double-quoted strings. However, this only works on keys, not values. toggle-quotes can toggle quotes normally on JSON keys, but can only toggle from double-quotes to single-quotes for JSON values - it can't toggle from single-quotes to double-quotes.

Steps to reproduce:

  1. Create JSON file with single-quote string attribute values.
  2. Try running toggle-quotes (either via the keyboard shortcut or via the command palette) on any of these values.

Ubuntu 14.04.1 LTS

mnquintana commented 9 years ago

Hmmm, can't reproduce on Yosemite. I'll check again tomorrow at work on my Ubuntu.

Aerijo commented 6 years ago

This can be reproduced with the following

{
  "foo": "ba8r"
}

Toggling "foo" is fine, but the 8 in ba8r breaks the invalid range and prevents this package from recognising it as a string. The same goes for anything that is potentially valid JSON syntax (e.g., ba{r)