Quote character in comment causes auto-indent error · Issue #648 · atom/language-javascript · GitHub
Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Quote character in comment causes auto-indent error #648

Closed

Description

@wbt

Description

When a comment contains a quote character (' or ") on a line which should be followed by an additional level of indentation, all following lines are indented one level less than they should be.

Steps to Reproduce

  1. In Atom, create a new Javascript file. (Optionally configure 1 indent = 4 spaces).
  2. Write or paste code like the following:
if(firstBoolean) {
    var myVar1 = "Indentation from the first conditional makes the issue more visible.";
    if(secondBoolean) { //this comment has at least one "double-quote" character in it
        var myVar2 = "This content and everything that follows is one indent level left of correct.";
        return myvar2;
    }
}
  1. Select All.
  2. Auto-indent.

Expected behavior:
Code formatted like the sample above.
Note that the close curly brace for the if (secondBoolean) is aligned with the if statement, and the contents of that conditional block are indented one level farther right.

Actual behavior:

if(firstBoolean) {
    var myVar1 = "Indentation from the first conditional makes the issue more visible.";
    if(secondBoolean) { //this comment has at least one "double-quote" character in it
    var myVar2 = "This content and everything that follows is one indent level left of correct.";
    return myvar2;
}
}

Note that everything after if(secondBoolean) is indented one level less than it should be, until the point when there is no further left the code can go.

Removing all quote characters and doing another auto-indent causes proper alignment. It does not appear to matter where in the comment the quote character appears. Even a quote character in a contraction will trigger the bug.

Reproduces how often:
Always, even in safe mode.

Versions

Atom : 1.23.2
Electron: 1.6.15
Chrome : 56.0.2924.87
Node : 7.4.0
Windows: 10 Pro

Activity

  1. rsese commented on May 30, 2019

    @rsese

    Thanks agin for reporting @wbt ✌️ Reproduced with 1.37.0 on macOS 10.12.6.

    As a side note, there's an open pull request to use Tree-sitter for indentation which may fix this issue if you want to subscribe there for updates: atom/atom#18321.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions