diff --git a/lib/ace/editor.js b/lib/ace/editor.js index 4bdb01f0..93096b5f 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -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(); diff --git a/lib/ace/mode/markdown.js b/lib/ace/mode/markdown.js index 969c3061..85cdff1e 100644 --- a/lib/ace/mode/markdown.js +++ b/lib/ace/mode/markdown.js @@ -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); } diff --git a/lib/ace/mode/php.js b/lib/ace/mode/php.js index aeea09c6..a73f3e84 100644 --- a/lib/ace/mode/php.js +++ b/lib/ace/mode/php.js @@ -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;