diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index e70d05c5..3d3e95d2 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -946,7 +946,8 @@ var EditSession = function(text, mode) { this.tokenRe = mode.tokenRe; this.nonTokenRe = mode.nonTokenRe; - + this.$options.wrapMethod.set.call(this, this.$wrapMethod); + if (!$isPlaceholder) { this.$setFolding(mode.foldingRules); this._emit("changeMode"); @@ -1791,7 +1792,7 @@ var EditSession = function(text, mode) { while (row <= lastRow) { foldLine = this.getFoldLine(row, foldLine); if (!foldLine) { - tokens = this.$getDisplayTokens(lang.stringTrimRight(lines[row])); + tokens = this.$getDisplayTokens(lines[row]); wrapData[row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize); row ++; } else { @@ -1815,9 +1816,6 @@ var EditSession = function(text, mode) { foldLine.end.row, lines[foldLine.end.row].length + 1 ); - // Remove spaces/tabs from the back of the token array. - while (tokens.length != 0 && tokens[tokens.length - 1] >= SPACE) - tokens.pop(); wrapData[foldLine.start.row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize); @@ -1931,7 +1929,7 @@ var EditSession = function(text, mode) { // === ELSE === // Search for the first non space/tab/placeholder/punctuation token backwards. - var minSplit = Math.max(split - (isCode ? 10 : wrapLimit >> 1), lastSplit - 1); + var minSplit = Math.max(split - (isCode ? 10 : wrapLimit-(wrapLimit>>2)), lastSplit - 1); while (split > minSplit && tokens[split] < PLACEHOLDER_START) { split --; } @@ -2450,6 +2448,16 @@ config.defineOptions(EditSession.prototype, "session", { return this.getUseWrapMode() ? this.getWrapLimitRange().min || "free" : "off"; }, handlesSet: true + }, + wrapMethod: { + // code|text|auto + set: function(val) { + if (val == "auto") + this.$wrapAsCode = this.$mode.type != "text"; + else + this.$wrapAsCode = val != "text"; + }, + initialValue: "auto" }, firstLineNumber: { set: function() {this._emit("changeBreakpoint");}, @@ -2486,9 +2494,6 @@ config.defineOptions(EditSession.prototype, "session", { set: function(val) {this.doc.setNewLineMode(val)}, get: function() {return this.doc.getNewLineMode()}, handlesSet: true - }, - wrapAsCode: { - initialValue: false } }); diff --git a/lib/ace/edit_session_test.js b/lib/ace/edit_session_test.js index 0ad3e6fe..0fbaf3d3 100644 --- a/lib/ace/edit_session_test.js +++ b/lib/ace/edit_session_test.js @@ -386,11 +386,12 @@ module.exports = { assert.ok(splits[i] == assertEqual[i]); } } - + + EditSession.prototype.$wrapAsCode = true; // Basic splitting. computeAndAssert("foo bar foo bar", [ 12 ]); computeAndAssert("foo bar f bar", [ 12 ]); - computeAndAssert("foo bar f r", [ 14 ]); + computeAndAssert("foo bar f r", [ 12 ]); // 14 if we enable computeAndAssert("foo bar foo bar foo bara foo", [12, 25]); // Don't split if there is only whitespaces/tabs at the end of the line. @@ -406,7 +407,7 @@ module.exports = { computeAndAssert("foo \t \tbar", [ 7 ]); // Ignore spaces/tabs at beginning of split. - computeAndAssert("foo \t \t \t \t bar", [ 14 ]); + computeAndAssert("foo \t \t \t \t bar", [ 7 ]); // 14 // Test wrapping for asian characters. computeAndAssert("ぁぁ", [1], 2); @@ -418,6 +419,10 @@ module.exports = { computeAndAssert(" ab.c;ef++", [1, 3, 5, 7, 8], 2); computeAndAssert(" a.b", [1, 2, 3], 1); computeAndAssert("#>>", [1, 2], 1); + + // Test wrapping for punctuation in + EditSession.prototype.$wrapAsCode = false; + computeAndAssert("ab cde, Juhu kinners", [3, 8, 13, 19], 6); }, "test get longest line" : function() { diff --git a/lib/ace/editor.js b/lib/ace/editor.js index 6aa2b2cc..fb41ac21 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -226,7 +226,7 @@ var Editor = function(renderer, session) { _self.keyBinding.setKeyboardHandler(module && module.handler); }); } else { - delete this.$keybindingId; + this.$keybindingId = null; this.keyBinding.setKeyboardHandler(keyboardHandler); } }; diff --git a/lib/ace/layer/text.js b/lib/ace/layer/text.js index a54f9250..ed926584 100644 --- a/lib/ace/layer/text.js +++ b/lib/ace/layer/text.js @@ -457,9 +457,9 @@ var Text = function(parentEl) { return screenColumn + value.length; }; - this.renderIndentGuide = function(stringBuilder, value) { + this.renderIndentGuide = function(stringBuilder, value, max) { var cols = value.search(this.$indentGuideRe); - if (cols <= 0) + if (cols <= 0 || cols >= max) return value; if (value[0] == " ") { cols -= cols % this.tabSize; @@ -483,7 +483,7 @@ var Text = function(parentEl) { var value = token.value; if (i == 0 && this.displayIndentGuides) { chars = value.length; - value = this.renderIndentGuide(stringBuilder, value); + value = this.renderIndentGuide(stringBuilder, value, splitChars); if (!value) continue; chars -= value.length; diff --git a/lib/ace/mode/asciidoc.js b/lib/ace/mode/asciidoc.js index b4e83f67..be0bf88b 100644 --- a/lib/ace/mode/asciidoc.js +++ b/lib/ace/mode/asciidoc.js @@ -46,6 +46,7 @@ var Mode = function() { oop.inherits(Mode, TextMode); (function() { + this.type = "text"; this.getNextLineIndent = function(state, line, tab) { if (state == "listblock") { var match = /^((?:.+)?)([-+*][ ]+)/.exec(line); diff --git a/lib/ace/mode/erlang.js b/lib/ace/mode/erlang.js index 8dcb42ea..adcb0a97 100644 --- a/lib/ace/mode/erlang.js +++ b/lib/ace/mode/erlang.js @@ -26,11 +26,6 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * - * Contributor(s): - * - * - * * ***** END LICENSE BLOCK ***** */ /* diff --git a/lib/ace/mode/markdown.js b/lib/ace/mode/markdown.js index 8b3a96d7..678b2a0d 100644 --- a/lib/ace/mode/markdown.js +++ b/lib/ace/mode/markdown.js @@ -56,7 +56,7 @@ var Mode = function() { oop.inherits(Mode, TextMode); (function() { - + this.type = "text"; this.lineCommentStart = ">"; this.getNextLineIndent = function(state, line, tab) { diff --git a/lib/ace/mode/plain_text.js b/lib/ace/mode/plain_text.js index 85e81d45..b093e736 100644 --- a/lib/ace/mode/plain_text.js +++ b/lib/ace/mode/plain_text.js @@ -38,18 +38,17 @@ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var Behaviour = require("./behaviour").Behaviour; var Mode = function() { - this.$tokenizer = new Tokenizer(new TextHighlightRules().getRules()); - this.$behaviour = new Behaviour(); + this.$tokenizer = new Tokenizer(new TextHighlightRules().getRules()); + this.$behaviour = new Behaviour(); }; oop.inherits(Mode, TextMode); (function() { - - this.getNextLineIndent = function(state, line, tab) { - return ''; - }; - + this.type = "text"; + this.getNextLineIndent = function(state, line, tab) { + return ''; + }; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/lib/ace/theme/tomorrow.css b/lib/ace/theme/tomorrow.css index f8f05614..3776a944 100644 --- a/lib/ace/theme/tomorrow.css +++ b/lib/ace/theme/tomorrow.css @@ -8,8 +8,7 @@ background: #f6f6f6 } -.ace-tomorrow, -.ace-tomorrow .ace_scroller { +.ace-tomorrow { background-color: #FFFFFF; color: #4D4D4C }