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