atom / toggle-quotes

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

Determine the string scope selector dynamically #53

Closed bartocc closed 6 years ago

bartocc commented 7 years ago

Description of the Change

In typescript, running 'toggle-quotes:toggle' in a template string does not cycle the quotes even after setting 'toggle-quotes.quoteCharacters' to '\'"`'

This happends because we try to get the editor range based on the scope selector ".string.quoted" which is not correct in .ts files for template strings.

This PR determines the correct scope dynamically by finding the current scope matching /^string./ and uses this scope to get the editor's range.

Alternate Designs

NA

Why Should This Be In Core?

Since we can configure toggle-quotes.quoteCharacters by adding the backtick, the package should be able to cycle from the backtick.

Benefits

See above

Possible Drawbacks

Might break for some languages that do not use /^string./ for string scopes ...

Applicable Issues

35 #51

bartocc commented 7 years ago

At the moment, I cannot run the specs since I get a timeout error when trying to return atom.packages.activatePackage('atom-typescript')

Any idea what I am doing wrong ?

winstliu commented 7 years ago

atom-typescript isn't installed by default. You would need to modify the CI script to install it, or use the new language-typescript grammar that is included with Atom 1.21+.

bartocc commented 6 years ago

closing because I don't use atom anymore