You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 16, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 16, 2026. It is now read-only.
Fat arrow operator in a quoted string throws off auto indent in JavaScript mode #2993
I first noticed this when trying to add new code to the bottom of a JavaScript source file using a CodeMirror based editor. The auto indent would ignore the actual indentation of my code and always jump over to the same strange place. I finally narrowed it down to this line in my source file:
Auto indent would be completely thrown off for any new line inserted into the source after the line above. It comes down to the quoted fat arrow "=>".
I added a test to the javascript mode that partly reproduces the issue. You can see the test here: d51a9e3
(I wasn't sure if I should do a pull request since this commit contains a failing test)
I also added a passing test that demonstrates how it should tokenize.
I used the test above to step into CodeMirror, and it appears findFatArrow does not take into consideration in its lookahead that the fat arrow may be quoted. However, I'm not real sure about that since I am new to CodeMirror and am not yet familiar enough with the codebase to know how to correctly solve this issue.
I thought I'd put this out there in case someone more familiar with the codebase knows a simple and easy solution. Otherwise, if need be, I can take the time to familiarize myself with the codebase and submit a pull request with a fix. Just let me know.
changed the title [-]Fat arrow operator in a quoted string throws off auto indent[/-][+]Fat arrow operator in a quoted string throws off auto indent in JavaScript mode[/+]on Dec 18, 2014
Activity
[-]Fat arrow operator in a quoted string throws off auto indent[/-][+]Fat arrow operator in a quoted string throws off auto indent in JavaScript mode[/+]marijnh commentedon Dec 19, 2014
The look-ahead hack that detected fat arrows was a bit too liberal. Attached patch should help.
[javascript mode] don't detect backtick-enclosed fatarrows
[javascript mode] don't detect backtick-enclosed fatarrows
[javascript mode] don't detect backtick-enclosed fatarrows
Update from master (#1)