From d03e5d1120d80a738c82459f2bdb587aa5e8ef41 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 24 Nov 2013 16:09:52 +0400 Subject: [PATCH 1/9] add selectOrFindNext commands and disable sublime ctrl-d like behavior of ctrl-arrow --- lib/ace/commands/default_commands.js | 20 ++++++++++++++++++++ lib/ace/multi_select.js | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/ace/commands/default_commands.js b/lib/ace/commands/default_commands.js index 0ba9956c..fa4592a0 100644 --- a/lib/ace/commands/default_commands.js +++ b/lib/ace/commands/default_commands.js @@ -127,6 +127,26 @@ exports.commands = [{ bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"), exec: function(editor) { editor.findPrevious(); }, readOnly: true +}, { + name: "selectOrFindNext", + bindKey: bindKey("ALt-K", "Ctrl-G"), + exec: function(editor) { + if (editor.selection.isEmpty()) + editor.selection.selectWord(); + else + editor.findNext(); + }, + readOnly: true +}, { + name: "selectOrFindPrevious", + bindKey: bindKey("Alt-Shift-K", "Ctrl-Shift-G"), + exec: function(editor) { + if (editor.selection.isEmpty()) + editor.selection.selectWord(); + else + editor.findPrevious(); + }, + readOnly: true }, { name: "find", bindKey: bindKey("Ctrl-F", "Command-F"), diff --git a/lib/ace/multi_select.js b/lib/ace/multi_select.js index 2152275e..7f4c5355 100644 --- a/lib/ace/multi_select.js +++ b/lib/ace/multi_select.js @@ -696,7 +696,8 @@ var Editor = require("./editor").Editor; range = session.getWordRange(range.start.row, range.start.column); range.cursor = dir == -1 ? range.start : range.end; this.multiSelect.addRange(range); - return; + // todo add option for sublime like behavior + // return; } var needle = session.getTextRange(range); From 1704cbdcc2167baca4bacd2cc75a431746c8205b Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 24 Nov 2013 16:10:40 +0400 Subject: [PATCH 2/9] check for valid start state in tokenizer --- lib/ace/tokenizer.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ace/tokenizer.js b/lib/ace/tokenizer.js index 5a9aaad4..1866881a 100644 --- a/lib/ace/tokenizer.js +++ b/lib/ace/tokenizer.js @@ -95,7 +95,7 @@ var Tokenizer = function(rules) { if (matchcount > 1) { if (/\\\d/.test(rule.regex)) { // Replace any backreferences and offset appropriately. - adjustedregex = rule.regex.replace(/\\([0-9]+)/g, function (match, digit) { + adjustedregex = rule.regex.replace(/\\([0-9]+)/g, function(match, digit) { return "\\" + (parseInt(digit, 10) + matchTotal + 1); }); } else { @@ -222,6 +222,10 @@ var Tokenizer = function(rules) { var currentState = startState || "start"; var state = this.states[currentState]; + if (!state) { + currentState = "start"; + state = this.states[currentState]; + } var mapping = this.matchMappings[currentState]; var re = this.regExps[currentState]; re.lastIndex = 0; From b88bf398b5a9789bacb56b72570b115637f290f2 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 24 Nov 2013 16:11:51 +0400 Subject: [PATCH 3/9] smoother resizing #1687 --- lib/ace/css/editor.css | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/ace/css/editor.css b/lib/ace/css/editor.css index 96cc27d7..025a6a15 100644 --- a/lib/ace/css/editor.css +++ b/lib/ace/css/editor.css @@ -25,6 +25,7 @@ -webkit-box-sizing: border-box; box-sizing: border-box; cursor: text; + min-width: 100%; } .ace_dragging, .ace_dragging * { From 9002950bf721111af985ddedf2d624371e4fbfb7 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 24 Nov 2013 16:13:36 +0400 Subject: [PATCH 4/9] rename group to aceCommandGroup to not conflict with cloud9 --- lib/ace/commands/default_commands.js | 8 +++--- lib/ace/editor.js | 42 ++++++++++++++-------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/lib/ace/commands/default_commands.js b/lib/ace/commands/default_commands.js index fa4592a0..e4a8212e 100644 --- a/lib/ace/commands/default_commands.js +++ b/lib/ace/commands/default_commands.js @@ -165,14 +165,14 @@ exports.commands = [{ exec: function(editor) { editor.getSelection().selectFileStart(); }, multiSelectAction: "forEach", readOnly: true, - group: "fileJump" + aceCommandGroup: "fileJump" }, { name: "gotostart", bindKey: bindKey("Ctrl-Home", "Command-Home|Command-Up"), exec: function(editor) { editor.navigateFileStart(); }, multiSelectAction: "forEach", readOnly: true, - group: "fileJump" + aceCommandGroup: "fileJump" }, { name: "selectup", bindKey: bindKey("Shift-Up", "Shift-Up"), @@ -191,14 +191,14 @@ exports.commands = [{ exec: function(editor) { editor.getSelection().selectFileEnd(); }, multiSelectAction: "forEach", readOnly: true, - group: "fileJump" + aceCommandGroup: "fileJump" }, { name: "gotoend", bindKey: bindKey("Ctrl-End", "Command-End|Command-Down"), exec: function(editor) { editor.navigateFileEnd(); }, multiSelectAction: "forEach", readOnly: true, - group: "fileJump" + aceCommandGroup: "fileJump" }, { name: "selectdown", bindKey: bindKey("Shift-Down", "Shift-Down"), diff --git a/lib/ace/editor.js b/lib/ace/editor.js index 5ce8135a..9c4e5ef3 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -110,17 +110,17 @@ var Editor = function(renderer, session) { oop.implement(this, EventEmitter); this.$initOperationListeners = function() { - function last(a) {return a[a.length - 1]}; + function last(a) {return a[a.length - 1]} this.selections = []; this.commands.on("exec", function(e) { this.startOperation(e); var command = e.command; - if (command.group == "fileJump") { + if (command.aceCommandGroup == "fileJump") { var prev = this.prevOp; - if (!prev || prev.command.group != "fileJump") { - this.lastFileJumpPos = last(this.selections) + if (!prev || prev.command.aceCommandGroup != "fileJump") { + this.lastFileJumpPos = last(this.selections); } } else { this.lastFileJumpPos = null; @@ -130,10 +130,10 @@ var Editor = function(renderer, session) { this.commands.on("afterExec", function(e) { var command = e.command; - if (command.group == "fileJump") { + if (command.aceCommandGroup == "fileJump") { if (this.lastFileJumpPos && !this.curOp.selectionChanged) { this.selection.fromJSON(this.lastFileJumpPos); - return + return; } } this.endOperation(e); @@ -150,7 +150,7 @@ var Editor = function(renderer, session) { this.curOp || this.startOperation(); this.curOp.selectionChanged = true; }.bind(this), true); - } + }; this.curOp = null; this.prevOp = {}; @@ -218,12 +218,12 @@ var Editor = function(renderer, session) { shouldMerge = shouldMerge && this.mergeNextCommand // previous command allows to coalesce with - && (!/\s/.test(text) || /\s/.test(prev.args)) // previous insertion was of same type + && (!/\s/.test(text) || /\s/.test(prev.args)); // previous insertion was of same type this.mergeNextCommand = true; } else { shouldMerge = shouldMerge - && mergeableCommands.indexOf(e.command.name) !== -1// the command is mergeable + && mergeableCommands.indexOf(e.command.name) !== -1; // the command is mergeable } if ( @@ -689,7 +689,7 @@ var Editor = function(renderer, session) { this.$updateHighlightActiveLine(); } - var re = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp() + var re = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp(); this.session.highlight(re); this._emit("changeSelection"); @@ -1205,9 +1205,9 @@ var Editor = function(renderer, session) { if (range.end.column == 0) { var text = session.getTextRange(range); if (text[text.length - 1] == "\n") { - var line = session.getLine(range.end.row) + var line = session.getLine(range.end.row); if (/^\s+$/.test(line)) { - range.end.column = line.length + range.end.column = line.length; } } } @@ -1353,7 +1353,7 @@ var Editor = function(renderer, session) { session.indentRows(rows.first, rows.last, "\t"); return; } else if (range.start.column < range.end.column) { - var text = session.getTextRange(range) + var text = session.getTextRange(range); if (!/^\s+$/.test(text)) { var rows = this.$getSelectedRows(); session.indentRows(rows.first, rows.last, "\t"); @@ -1444,19 +1444,19 @@ var Editor = function(renderer, session) { * Works like [[EditSession.getTokenAt]], except it returns a number. * @returns {Number} **/ - this.getNumberAt = function( row, column ) { - var _numberRx = /[\-]?[0-9]+(?:\.[0-9]+)?/g - _numberRx.lastIndex = 0 + this.getNumberAt = function(row, column) { + var _numberRx = /[\-]?[0-9]+(?:\.[0-9]+)?/g; + _numberRx.lastIndex = 0; - var s = this.session.getLine(row) + var s = this.session.getLine(row); while (_numberRx.lastIndex < column) { - var m = _numberRx.exec(s) + var m = _numberRx.exec(s); if(m.index <= column && m.index+m[0].length >= column){ var number = { value: m[0], start: m.index, end: m.index+m[0].length - } + }; return number; } } @@ -1542,7 +1542,7 @@ var Editor = function(renderer, session) { range.start = point; range.end = endPoint; - sel.setSelectionRange(range, reverse) + sel.setSelectionRange(range, reverse); } }; @@ -1827,7 +1827,7 @@ var Editor = function(renderer, session) { var pos = { row: Math.floor(range.start.row + (range.end.row - range.start.row) / 2), column: Math.floor(range.start.column + (range.end.column - range.start.column) / 2) - } + }; this.renderer.alignCursor(pos, 0.5); }; From a910b8ee18de4394cff1ba9a1db05222ea304886 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 24 Nov 2013 16:15:52 +0400 Subject: [PATCH 5/9] do not freeze browser when calling fold all second time --- lib/ace/edit_session/folding.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/ace/edit_session/folding.js b/lib/ace/edit_session/folding.js index 9ebc2869..e4415fe1 100644 --- a/lib/ace/edit_session/folding.js +++ b/lib/ace/edit_session/folding.js @@ -128,13 +128,9 @@ function Folding() { var folds = []; var foldLines = this.$foldData; - function addFold(fold) { - folds.push(fold); - } - for (var i = 0; i < foldLines.length; i++) for (var j = 0; j < foldLines[i].folds.length; j++) - addFold(foldLines[i].folds[j]); + folds.push(foldLines[i].folds[j]); return folds; }; @@ -285,7 +281,7 @@ function Folding() { // --- Some checking --- if (!(startRow < endRow || - startRow == endRow && startColumn <= endColumn - 2)) + startRow == endRow && startColumn < endColumn - 2)) throw new Error("The range has to be at least 2 characters width"); var startFold = this.getFoldAt(startRow, startColumn, 1); @@ -655,12 +651,15 @@ function Folding() { if (range && range.isMultiLine() && range.end.row <= endRow && range.start.row >= startRow - ) try { - var fold = this.addFold("...", range); - fold.collapseChildren = depth; - // addFold can change the range + ) { row = range.end.row; - } catch(e) {} + try { + // addFold can change the range + var fold = this.addFold("...", range); + if (fold) + fold.collapseChildren = depth; + } catch(e) {} + } } }; @@ -753,6 +752,8 @@ function Folding() { }; this.$toggleFoldWidget = function(row, options) { + if (!this.getFoldWidget) + return; var type = this.getFoldWidget(row); var line = this.getLine(row); From 4cb1e7b849a61665db14eb0b9e43562362da5b59 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 24 Nov 2013 16:16:36 +0400 Subject: [PATCH 6/9] misc fixes --- lib/ace/edit_session.js | 2 +- lib/ace/mode/c9search_highlight_rules.js | 31 ++++++++++++------------ lib/ace/mode/javascript/jshint.js | 5 +++- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index ab6f8d71..eab30e92 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -952,8 +952,8 @@ var EditSession = function(text, mode) { if (!$isPlaceholder) { this.$options.wrapMethod.set.call(this, this.$wrapMethod); this.$setFolding(mode.foldingRules); - this._emit("changeMode"); this.bgTokenizer.start(0); + this._emit("changeMode"); } }; diff --git a/lib/ace/mode/c9search_highlight_rules.js b/lib/ace/mode/c9search_highlight_rules.js index 07273bbb..ce11bf5d 100644 --- a/lib/ace/mode/c9search_highlight_rules.js +++ b/lib/ace/mode/c9search_highlight_rules.js @@ -63,23 +63,22 @@ var C9SearchHighlightRules = function() { var regex = stack[1]; var str = values[3]; - if (regex && str) - values = str.split(regex); // this doesn't work on ie8 but we don't care:) - else - values = [str]; - for (var i = 0, l = values.length; i < l; i+=2) { - if (values[i]) - tokens.push({ - type: types[2], - value: values[i] - }); - if (values[i+1]) - tokens.push({ - type: types[3], - value: values[i + 1] - }); + var m; + var last = 0; + if (regex) { + regex.lastIndex = 0; + while (m = regex.exec(str)) { + var skipped = str.substring(last, m.index); + last = regex.lastIndex; + if (skipped) + tokens.push({type: types[2], value: skipped}); + if (m[0]) + tokens.push({type: types[3], value: m[0]}); + } } + if (last < str.length) + tokens.push({type: types[2], value: str.substr(last)}); return tokens; } }, @@ -102,7 +101,7 @@ var C9SearchHighlightRules = function() { search = "\\b" + search + "\\b"; var regex = safeCreateRegexp( "(" + search + ")", - / sensitive/.test(options) ? "" : "i" + / sensitive/.test(options) ? "g" : "ig" ); if (regex) { stack[0] = state; diff --git a/lib/ace/mode/javascript/jshint.js b/lib/ace/mode/javascript/jshint.js index 1faef4ce..04f36539 100644 --- a/lib/ace/mode/javascript/jshint.js +++ b/lib/ace/mode/javascript/jshint.js @@ -7875,7 +7875,7 @@ Lexer.prototype = { this.skip(); - while (this.peek() !== quote) { + outer: while (this.peek() !== quote) { while (this.peek() === "") { // End Of Line // If an EOL is not preceded by a backslash, show a warning @@ -7927,6 +7927,9 @@ Lexer.prototype = { quote: quote }; } + + if (this.peek() == quote) + break outer; } allowNewLine = false; From 9a2ee70af8b4ee1923f22c9003486ffa723e3cae Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 24 Nov 2013 16:18:13 +0400 Subject: [PATCH 7/9] allow starting and cancelling mouse capture from outside --- lib/ace/lib/event.js | 2 ++ lib/ace/mouse/mouse_handler.js | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/ace/lib/event.js b/lib/ace/lib/event.js index 691d0019..4d407dfc 100644 --- a/lib/ace/lib/event.js +++ b/lib/ace/lib/event.js @@ -112,6 +112,8 @@ exports.capture = function(el, eventHandler, releaseCaptureHandler) { exports.addListener(document, "mousemove", eventHandler, true); exports.addListener(document, "mouseup", onMouseUp, true); exports.addListener(document, "dragstart", onMouseUp, true); + + return onMouseUp; }; exports.addMouseWheelListener = function(el, callback) { diff --git a/lib/ace/mouse/mouse_handler.js b/lib/ace/mouse/mouse_handler.js index 2565bd19..d9f6188f 100644 --- a/lib/ace/mouse/mouse_handler.js +++ b/lib/ace/mouse/mouse_handler.js @@ -115,6 +115,8 @@ var MouseHandler = function(editor) { self.x = e.clientX; self.y = e.clientY; mouseMoveHandler && mouseMoveHandler(e); + self.mouseEvent = new MouseEvent(e, self.editor); + self.$mouseMoved = true; }; var onCaptureEnd = function(e) { @@ -127,20 +129,24 @@ var MouseHandler = function(editor) { renderer.$moveTextAreaToCursor(); } self.isMousePressed = false; + self.$onCaptureMouseMove = self.releaseMouse = null; self.onMouseEvent("mouseup", e); }; var onCaptureInterval = function() { self[self.state] && self[self.state](); + self.$mouseMoved = false; }; if (useragent.isOldIE && ev.domEvent.type == "dblclick") { return setTimeout(function() {onCaptureEnd(ev);}); } - event.capture(this.editor.container, onMouseMove, onCaptureEnd); + self.$onCaptureMouseMove = onMouseMove; + self.releaseMouse = event.capture(this.editor.container, onMouseMove, onCaptureEnd); var timerId = setInterval(onCaptureInterval, 20); }; + this.releaseMouse = null; }).call(MouseHandler.prototype); config.defineOptions(MouseHandler.prototype, "mouseHandler", { From 9b8e23648335103c215927e411782badc2266908 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 24 Nov 2013 16:19:59 +0400 Subject: [PATCH 8/9] do not modify dom from computeLayerConfig --- lib/ace/virtual_renderer.js | 90 +++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 44 deletions(-) diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index 3c992d20..80de9e7f 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -228,8 +228,6 @@ var VirtualRenderer = function(container, theme) { if (this.scrollMargin.top && session.getScrollTop() <= 0) session.setScrollTop(-this.scrollMargin.top); - this.scroller.className = "ace_scroller"; - this.$cursorLayer.setSession(session); this.$markerBack.setSession(session); this.$markerFront.setSession(session); @@ -359,6 +357,7 @@ var VirtualRenderer = function(container, theme) { }; this.$updateCachedSize = function(force, gutterWidth, width, height) { + height -= (this.$extraHeight || 0); var changes = 0; var size = this.$size; var oldSize = { @@ -407,8 +406,7 @@ var VirtualRenderer = function(container, theme) { changes = changes | this.CHANGE_FULL; } - if (size.$dirty) - size.$dirty = !width && !height; + size.$dirty = !width || !height; if (changes) this._signal("resize", oldSize); @@ -749,13 +747,22 @@ var VirtualRenderer = function(container, theme) { this.scrollBarH.setInnerWidth(this.layerConfig.width + 2 * this.$padding + this.scrollMargin.h); this.scrollBarH.setScrollLeft(this.scrollLeft + this.scrollMargin.left); }; + + this.$frozen = false; + this.freeze = function() { + this.$frozen = true; + }; + + this.unfreeze = function() { + this.$frozen = false; + }; this.$renderChanges = function(changes, force) { if (this.$changes) { changes |= this.$changes; this.$changes = 0; } - if ((!this.session || !this.container.offsetWidth) || (!changes && !force)) { + if ((!this.session || !this.container.offsetWidth || this.$frozen) || (!changes && !force)) { this.$changes |= changes; return; } @@ -769,6 +776,7 @@ var VirtualRenderer = function(container, theme) { // this.$logChanges(changes); this._signal("beforeRender"); + var config = this.layerConfig; // text, scrolling and resize changes can cause the view port size to change if (changes & this.CHANGE_FULL || changes & this.CHANGE_SIZE || @@ -776,27 +784,33 @@ var VirtualRenderer = function(container, theme) { changes & this.CHANGE_LINES || changes & this.CHANGE_SCROLL || changes & this.CHANGE_H_SCROLL - ) + ) { changes |= this.$computeLayerConfig(); - + config = this.layerConfig; + // update scrollbar first to not lose scroll position when gutter calls resize + this.$updateScrollBarV(); + if (changes & this.CHANGE_H_SCROLL) + this.$updateScrollBarH(); + this.$gutterLayer.element.style.marginTop = (-config.offset) + "px"; + this.content.style.marginTop = (-config.offset) + "px"; + this.content.style.width = config.width + 2 * this.$padding + "px"; + this.content.style.height = config.minHeight + "px"; + } + // horizontal scrolling if (changes & this.CHANGE_H_SCROLL) { - this.$updateScrollBarH(); this.content.style.marginLeft = -this.scrollLeft + "px"; this.scroller.className = this.scrollLeft <= 0 ? "ace_scroller" : "ace_scroller ace_scroll-left"; } // full if (changes & this.CHANGE_FULL) { - // update scrollbar first to not lose scroll position when gutter calls resize - this.$updateScrollBarV(); - this.$updateScrollBarH(); - this.$textLayer.update(this.layerConfig); + this.$textLayer.update(config); if (this.$showGutter) - this.$gutterLayer.update(this.layerConfig); - this.$markerBack.update(this.layerConfig); - this.$markerFront.update(this.layerConfig); - this.$cursorLayer.update(this.layerConfig); + this.$gutterLayer.update(config); + this.$markerBack.update(config); + this.$markerFront.update(config); + this.$cursorLayer.update(config); this.$moveTextAreaToCursor(); this.$highlightGutterLine && this.$updateGutterLineHighlight(); this._signal("afterRender"); @@ -805,17 +819,16 @@ var VirtualRenderer = function(container, theme) { // scrolling if (changes & this.CHANGE_SCROLL) { - this.$updateScrollBarV(); if (changes & this.CHANGE_TEXT || changes & this.CHANGE_LINES) - this.$textLayer.update(this.layerConfig); + this.$textLayer.update(config); else - this.$textLayer.scrollLines(this.layerConfig); + this.$textLayer.scrollLines(config); if (this.$showGutter) - this.$gutterLayer.update(this.layerConfig); - this.$markerBack.update(this.layerConfig); - this.$markerFront.update(this.layerConfig); - this.$cursorLayer.update(this.layerConfig); + this.$gutterLayer.update(config); + this.$markerBack.update(config); + this.$markerFront.update(config); + this.$cursorLayer.update(config); this.$highlightGutterLine && this.$updateGutterLineHighlight(); this.$moveTextAreaToCursor(); this._signal("afterRender"); @@ -823,49 +836,44 @@ var VirtualRenderer = function(container, theme) { } if (changes & this.CHANGE_TEXT) { - this.$textLayer.update(this.layerConfig); + this.$textLayer.update(config); if (this.$showGutter) - this.$gutterLayer.update(this.layerConfig); + this.$gutterLayer.update(config); } else if (changes & this.CHANGE_LINES) { if (this.$updateLines() || (changes & this.CHANGE_GUTTER) && this.$showGutter) - this.$gutterLayer.update(this.layerConfig); + this.$gutterLayer.update(config); } else if (changes & this.CHANGE_TEXT || changes & this.CHANGE_GUTTER) { if (this.$showGutter) - this.$gutterLayer.update(this.layerConfig); + this.$gutterLayer.update(config); } if (changes & this.CHANGE_CURSOR) { - this.$cursorLayer.update(this.layerConfig); + this.$cursorLayer.update(config); this.$moveTextAreaToCursor(); this.$highlightGutterLine && this.$updateGutterLineHighlight(); } if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_FRONT)) { - this.$markerFront.update(this.layerConfig); + this.$markerFront.update(config); } if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_BACK)) { - this.$markerBack.update(this.layerConfig); - } - - if (changes & this.CHANGE_SIZE || changes & this.CHANGE_LINES) { - this.$updateScrollBarV(); - this.$updateScrollBarH(); + this.$markerBack.update(config); } this._signal("afterRender"); }; - this.$autosize = function(height, width) { + this.$autosize = function() { var height = this.session.getScreenLength() * this.lineHeight; var maxHeight = this.$maxLines * this.lineHeight; var desiredHeight = Math.max( (this.$minLines||1) * this.lineHeight, Math.min(maxHeight, height) - ); + ) + this.scrollMargin.v + (this.$extraHeight || 0); var vScroll = height > maxHeight; if (desiredHeight != this.desiredHeight || @@ -890,7 +898,7 @@ var VirtualRenderer = function(container, theme) { var session = this.session; var hideScrollbars = this.$size.height <= 2 * this.lineHeight; - var screenLines = this.session.getScreenLength() + var screenLines = this.session.getScreenLength(); var maxHeight = screenLines * this.lineHeight; var offset = this.scrollTop % this.lineHeight; @@ -981,12 +989,6 @@ var VirtualRenderer = function(container, theme) { // For debugging. // console.log(JSON.stringify(this.layerConfig)); - this.$gutterLayer.element.style.marginTop = (-offset) + "px"; - this.content.style.marginTop = (-offset) + "px"; - this.content.style.width = longestLine + 2 * this.$padding + "px"; - this.content.style.height = minHeight + "px"; - - return changes; return changes; }; From 70bc7d7dc0d425abca9b7e946f688d6232b20b5d Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 24 Nov 2013 16:47:32 +0400 Subject: [PATCH 9/9] update tests --- lib/ace/edit_session/folding.js | 2 +- lib/ace/multi_select_test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ace/edit_session/folding.js b/lib/ace/edit_session/folding.js index e4415fe1..d3fa0ef0 100644 --- a/lib/ace/edit_session/folding.js +++ b/lib/ace/edit_session/folding.js @@ -281,7 +281,7 @@ function Folding() { // --- Some checking --- if (!(startRow < endRow || - startRow == endRow && startColumn < endColumn - 2)) + startRow == endRow && startColumn <= endColumn - 2)) throw new Error("The range has to be at least 2 characters width"); var startFold = this.getFoldAt(startRow, startColumn, 1); diff --git a/lib/ace/multi_select_test.js b/lib/ace/multi_select_test.js index 795aee2b..45ab4965 100644 --- a/lib/ace/multi_select_test.js +++ b/lib/ace/multi_select_test.js @@ -66,7 +66,7 @@ module.exports = { MultiSelect(editor); editor.navigateFileEnd(); - exec("selectMoreBefore", 4); + exec("selectMoreBefore", 3); assert.ok(editor.inMultiSelectMode); assert.equal(editor.selection.getAllRanges().length, 4);