Skip to content
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

Feature request: toggle document #21

Open
v-kydela opened this issue May 6, 2020 · 5 comments
Open

Feature request: toggle document #21

v-kydela opened this issue May 6, 2020 · 5 comments

Comments

@v-kydela
Copy link

v-kydela commented May 6, 2020

If I have a JSON document that is entirely single-quoted and I need to make it double-quoted, I'd have to select every property name and value one at a time. If that's outside the scope of this extension, is there another extension that could toggle quotes for the whole document?

@jeremychone
Copy link
Contributor

Interesting. yes, this would be outside. Now, what you could do, is do a regex multi selection, in the search,
image

There must be a way to select all matches. And then, toggle it. Should work.

@v-kydela
Copy link
Author

v-kydela commented May 6, 2020

That's tricky because Toggle Quotes only seems to work if the select text is exactly between a pair of quotes and not if the selected text includes the quotes.

If I try (["'`]).*?\1 then I get this

image

That won't work because the match includes the quotes and Toggle Quotes won't accept that

If I try (?<=(["'`])).*?(?=\1) then I get this

image

That won't work because of the text outside the quotes that still gets recognized as being between quotes (": ")

Finally, I came across this solution: (?<=["])[^"]*(?="(?:(?:[^"]*"){2})*[^"]*$)

It works only for one type of quote at a time, and it's still much more complicated than the other expressions. Would it be possible for the Toggle Quotes extension to be more lenient with what particular text needs to be selected?

@jeremychone
Copy link
Contributor

interesting. I understand the regex challenge.

The issue is that the "ignore selected" text is by design to allow a simple and custom way to "exclude" some text from the toggle change.

Now, perhaps, you can split it two steps. First get names '...':, before the ':, and then, another step with the : ' assuming all is formatted this way.

@v-kydela
Copy link
Author

v-kydela commented May 6, 2020

Could Toggle Quotes be split into two commands, "Toggle Quotes: Surrounding" and "Toggle Quotes: Within"? It seems like the "within" option would be even easier to implement than the original "surrounding" option, and it would give us the ability to select all and then toggle quotes for the whole document.

@jeremychone
Copy link
Contributor

This is a good idea. I added at #22.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants