Skip to content
This repository was archived by the owner on Apr 16, 2026. It is now read-only.
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

Closed

Description

@andrewdep

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:

      if (lexp == "or" || lexp == "and" || lexp == "!=" || lexp == "!" || lexp == ">" || lexp == "<" || lexp == ">=" || lexp == "<=" || lexp == "=>" || lexp == "=<" || lexp == '=' || lexp == '==' || lexp == '||' || lexp == '&&') {

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.

Activity

  1. 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
  2. marijnh commented on Dec 19, 2014

    @marijnh
    Member

    The look-ahead hack that detected fat arrows was a bit too liberal. Attached patch should help.

  3. added a commit that references this issue on Jan 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions