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
@wbt

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

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions