add autoindent after { and brace pairing for logiql

This commit is contained in:
nightwing 2013-03-27 14:19:42 +04:00
commit 74f38ffd6a

View file

@ -38,11 +38,15 @@ var LogiQLHighlightRules = require("./logiql_highlight_rules").LogiQLHighlightRu
var FoldMode = require("./folding/coffee").FoldMode;
var TokenIterator = require("../token_iterator").TokenIterator;
var Range = require("../range").Range;
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
var Mode = function() {
var highlighter = new LogiQLHighlightRules();
this.foldingRules = new FoldMode();
this.$tokenizer = new Tokenizer(highlighter.getRules());
this.$outdent = new MatchingBraceOutdent();
this.$behaviour = new CstyleBehaviour();
};
oop.inherits(Mode, TextMode);
@ -62,12 +66,15 @@ oop.inherits(Mode, TextMode);
return indent;
var match = line.match();
if (/(-->|<--|<-|->)\s*$/.test(line))
if (/(-->|<--|<-|->|{)\s*$/.test(line))
indent += tab;
return indent;
};
this.checkOutdent = function(state, line, input) {
if (this.$outdent.checkOutdent(line, input))
return true;
if (input !== "\n" && input !== "\r\n")
return false;
@ -78,6 +85,8 @@ oop.inherits(Mode, TextMode);
};
this.autoOutdent = function(state, doc, row) {
if (this.$outdent.autoOutdent(doc, row))
return;
var prevLine = doc.getLine(row);
var match = prevLine.match(/^\s+/);
var column = prevLine.lastIndexOf(".") + 1;