commit
0f25bfb0e5
3 changed files with 23 additions and 11 deletions
|
|
@ -666,7 +666,6 @@ var Editor = function(renderer, session) {
|
|||
this.insert = function(text) {
|
||||
var session = this.session;
|
||||
var mode = session.getMode();
|
||||
|
||||
var cursor = this.getCursorPosition();
|
||||
|
||||
if (this.getBehavioursEnabled()) {
|
||||
|
|
@ -693,9 +692,8 @@ var Editor = function(renderer, session) {
|
|||
|
||||
var start = cursor.column;
|
||||
var lineState = session.getState(cursor.row);
|
||||
var shouldOutdent = mode.checkOutdent(lineState, session.getLine(cursor.row), text);
|
||||
var line = session.getLine(cursor.row);
|
||||
var lineIndent = mode.getNextLineIndent(lineState, line.slice(0, cursor.column), session.getTabString());
|
||||
var shouldOutdent = mode.checkOutdent(lineState, line, text);
|
||||
var end = session.insert(cursor, text);
|
||||
|
||||
if (transform && transform.selection) {
|
||||
|
|
@ -712,12 +710,12 @@ var Editor = function(renderer, session) {
|
|||
}
|
||||
}
|
||||
|
||||
var lineState = session.getState(cursor.row);
|
||||
|
||||
// TODO disabled multiline auto indent
|
||||
// possibly doing the indent before inserting the text
|
||||
// if (cursor.row !== end.row) {
|
||||
if (session.getDocument().isNewLine(text)) {
|
||||
var lineIndent = mode.getNextLineIndent(lineState, line.slice(0, cursor.column), session.getTabString());
|
||||
|
||||
this.moveCursorTo(cursor.row+1, 0);
|
||||
|
||||
var size = session.getTabSize();
|
||||
|
|
|
|||
|
|
@ -58,12 +58,13 @@ oop.inherits(Mode, TextMode);
|
|||
(function() {
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
if (state == "listblock") {
|
||||
var match = /^((?:.+)?)(([-+*]|\d+\.)\s+)/.exec(line);
|
||||
if (match) {
|
||||
return new Array(match[1].length + 1).join(" ") + match[2];
|
||||
} else {
|
||||
var match = /^(\s*)(?:([-+*])|(\d+)\.)(\s+)/.exec(line);
|
||||
if (!match)
|
||||
return "";
|
||||
}
|
||||
var marker = match[2];
|
||||
if (!marker)
|
||||
marker = parseInt(match[3], 10) + 1 + ".";
|
||||
return match[1] + marker + match[4];
|
||||
} else {
|
||||
return this.$getIndent(line);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,16 +98,29 @@ oop.inherits(Mode, TextMode);
|
|||
|
||||
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
|
||||
var tokens = tokenizedLine.tokens;
|
||||
var endState = tokenizedLine.state;
|
||||
|
||||
|
||||
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
||||
return indent;
|
||||
}
|
||||
|
||||
if (state == "start") {
|
||||
if (state == "php-start") {
|
||||
var match = line.match(/^.*[\{\(\[\:]\s*$/);
|
||||
if (match) {
|
||||
indent += tab;
|
||||
}
|
||||
} else if (state == "php-doc-start") {
|
||||
if (endState != "php-doc-start") {
|
||||
return "";
|
||||
}
|
||||
var match = line.match(/^\s*(\/?)\*/);
|
||||
if (match) {
|
||||
if (match[1]) {
|
||||
indent += " ";
|
||||
}
|
||||
indent += "* ";
|
||||
}
|
||||
}
|
||||
|
||||
return indent;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue