Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Don't try to indent case or default statements
Browse files Browse the repository at this point in the history
Using the current regexp-based indentation system, we either
have to indent these statements the way that textmate does,
which is non-standard, or the way sublime does, which requires
the user to manually type tab after a case or default statement.
I've chosen sublime's way for now, because it makes it easier
to achieve the most common indentation style.

Closes #49
  • Loading branch information
maxbrunsfeld committed Apr 14, 2015
1 parent 3028ec9 commit 21fae9f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 0 additions & 2 deletions settings/language-javascript.cson
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
\\{ [^}"\']* $
| \\[ [^\\]"\']* $
| \\( [^)"\']* $
| case[\\s\\S]*: $
| default: $
'
'decreaseIndentPattern': '(?x)
^ \\s* (\\s* /[*] .* [*]/ \\s*)* [}\\])]
Expand Down
10 changes: 10 additions & 0 deletions spec/javascript-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,16 @@ describe "Javascript grammar", ->
}
"""

it "doesn't indent case statements, because it wouldn't know when to outdent", ->
expectPreservedIndentation """
switch (e) {
case 5:
something();
case 6:
somethingElse();
}
"""

it "indents collection literals", ->
expectPreservedIndentation """
[
Expand Down

0 comments on commit 21fae9f

Please sign in to comment.