mooz / js2-mode

Improved JavaScript editing mode for GNU Emacs
GNU General Public License v3.0
1.33k stars 186 forks source link

Nested template literals indent strangely #520

Open lambdadog opened 5 years ago

lambdadog commented 5 years ago

Noticed some strange behavior with indentation when nesting template literals. I imagine this is because inbuilt parsing is used to detect when inside strings for indentation, and this is causing it to understand the inside of the second template literal as the end of the first one and so on

test_fun(test`
this works
${test`
     this doesn't
     ${test`
this does again
`}`}`);
dgutov commented 5 years ago

True. But please see the second item here: https://github.com/mooz/js2-mode#bugs

lambdadog commented 5 years ago

@dgutov do template literals fall under the scope of js-mode though? i wasn't aware js-mode was intended to support es6 features

The current features that are supporting template literals in js-mode are just supporting "multiline strings" (and accordingly, in js-mode the interpolated code is just highlighted as another part of the string) which is why i chose to open the issue here instead

dgutov commented 5 years ago

That's a fair question. js-mode does support template literals to an extent, but maybe nested ones will give it some trouble.

We do rely on its indentation logic, though, so trying to support them there first would be natural.