meganrogge / template-string-converter

Autocorrect from quotes to backticks
MIT License
194 stars 24 forks source link

Support multiple cursors #46

Closed laymonage closed 3 years ago

laymonage commented 3 years ago

Hi,

First of all, thanks for the extension, it's really helpful!

I encountered an issue when trying to use template strings with multiple cursors (e.g. press Shift + Alt + ↑/↓). If I type $ followed by {, I would lose all cursors except the last one, and only the last cursor will have the correct result (changing to ` and have the } automatically inserted).

Would it be possible to fix this in a future release?

Thanks!

meganrogge commented 3 years ago

Hey, this used to work. Thanks for bringing it to my attention. I'll look into the fix

meganrogge commented 3 years ago

Okay I think I know what's going on here actually the extension assumes that the lines have a proper end to them (like a semi-colon). It relies upon this as a way to distinguish whether or not the current change is within backticks.

This is to prevent conversion from happening for example in this case (multi-line):

`
${text}
`

recording - 2021-05-24T093650 476

innocenzi commented 3 years ago

Hey, sorry to bump, does this mean this extension doesn't have (and won't) support for multiple cursors when not using semi-colons?

meganrogge commented 3 years ago

@innocenzi that's correct. if there's a high demand for such a feature, I'll consider supporting it under a setting, but think that most use cases involve semi-colon terminated lines

innocenzi commented 3 years ago

I think semicolonless code is pretty common (eg. standardjs, or big projects like Vite), so I think this could be useful. But no big deal if you don't have the time for this