don't autoindent in object literal. fix #508
This commit is contained in:
parent
09a04bdc32
commit
c4d3d68a19
2 changed files with 9 additions and 6 deletions
|
|
@ -57,7 +57,6 @@ oop.inherits(Mode, TextMode);
|
|||
|
||||
this.toggleCommentLines = function(state, doc, startRow, endRow) {
|
||||
var outdent = true;
|
||||
var outentedRows = [];
|
||||
var re = /^(\s*)\/\//;
|
||||
|
||||
for (var i=startRow; i<= endRow; i++) {
|
||||
|
|
@ -96,7 +95,7 @@ oop.inherits(Mode, TextMode);
|
|||
}
|
||||
|
||||
if (state == "start" || state == "regex_allowed") {
|
||||
var match = line.match(/^.*[\{\(\[\:]\s*$/);
|
||||
var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
|
||||
if (match) {
|
||||
indent += tab;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,14 +63,14 @@ module.exports = {
|
|||
"test: toggle comment lines should prepend '//' to each line" : function() {
|
||||
var session = new EditSession([" abc", "cde", "fg"]);
|
||||
|
||||
var comment = this.mode.toggleCommentLines("start", session, 0, 1);
|
||||
this.mode.toggleCommentLines("start", session, 0, 1);
|
||||
assert.equal(["// abc", "//cde", "fg"].join("\n"), session.toString());
|
||||
},
|
||||
|
||||
"test: toggle comment on commented lines should remove leading '//' chars" : function() {
|
||||
var session = new EditSession(["// abc", "//cde", "fg"]);
|
||||
|
||||
var comment = this.mode.toggleCommentLines("start", session, 0, 1);
|
||||
this.mode.toggleCommentLines("start", session, 0, 1);
|
||||
assert.equal([" abc", "cde", "fg"].join("\n"), session.toString());
|
||||
},
|
||||
|
||||
|
|
@ -85,14 +85,14 @@ module.exports = {
|
|||
"test: toggle comment on multiple lines with one commented line prepend '//' to each line" : function() {
|
||||
var session = new EditSession(["// abc", "//cde", "fg"]);
|
||||
|
||||
var comment = this.mode.toggleCommentLines("start", session, 0, 2);
|
||||
this.mode.toggleCommentLines("start", session, 0, 2);
|
||||
assert.equal(["//// abc", "////cde", "//fg"].join("\n"), session.toString());
|
||||
},
|
||||
|
||||
"test: toggle comment on a comment line with leading white space": function() {
|
||||
var session = new EditSession(["//cde", " //fg"]);
|
||||
|
||||
var comment = this.mode.toggleCommentLines("start", session, 0, 1);
|
||||
this.mode.toggleCommentLines("start", session, 0, 1);
|
||||
assert.equal(["cde", " fg"].join("\n"), session.toString());
|
||||
},
|
||||
|
||||
|
|
@ -104,6 +104,10 @@ module.exports = {
|
|||
assert.equal(" ", this.mode.getNextLineIndent("start", "case 'juhu':", " "));
|
||||
},
|
||||
|
||||
"test: no auto indent in object literal" : function() {
|
||||
assert.equal("", this.mode.getNextLineIndent("start", "{ 'juhu':", " "));
|
||||
},
|
||||
|
||||
"test: no auto indent after opening brace in multi line comment" : function() {
|
||||
assert.equal("", this.mode.getNextLineIndent("start", "/*if () {", " "));
|
||||
assert.equal(" ", this.mode.getNextLineIndent("comment", " abcd", " "));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue