From 107735560a3e17d7af385d1506c67da1e3902f12 Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 20 Mar 2012 00:02:24 +0400 Subject: [PATCH] do not require cursors to be sorted --- lib/ace/layer/cursor.js | 46 +++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/lib/ace/layer/cursor.js b/lib/ace/layer/cursor.js index 0fc42e86..c2a7ca28 100644 --- a/lib/ace/layer/cursor.js +++ b/lib/ace/layer/cursor.js @@ -141,37 +141,33 @@ var Cursor = function(parentEl) { this.update = function(config) { this.config = config; - if (!this.session.selection.multiSelectMode) { - this.pixelPos = this.getPixelPosition(null, true); + if (this.session.selection.rangeCount > 1) { + var selections = this.session.selection.allRanges + var i = 0, sel, cursorIndex = 0; + + for (var i = selections.length; i--; ) { + sel = selections[i]; + var pixelPos = this.getPixelPosition(sel.cursor, true); + + var style = (this.cursors[cursorIndex++] || this.addCursor()).style; + + style.left = pixelPos.left + "px"; + style.top = pixelPos.top + "px"; + style.width = config.characterWidth + "px"; + style.height = config.lineHeight + "px"; + } + while (cursorIndex < this.cursors.length) + this.removeCursor(); + } else { + var pixelPos = this.getPixelPosition(null, true); var style = this.cursor.style; - style.left = this.pixelPos.left + "px"; - style.top = this.pixelPos.top + "px"; + style.left = pixelPos.left + "px"; + style.top = pixelPos.top + "px"; style.width = config.characterWidth + "px"; style.height = config.lineHeight + "px"; while (this.cursors.length > 1) this.removeCursor(); - } else { - var selections = this.session.selection.allRanges - var i = 0, sel, cursorIndex = 0; - - while ((sel = selections[i]) && sel.cursor.row < config.firstRow) - i++; - - while ((sel = selections[i]) && sel.cursor.row < config.lastRow) { - this.pixelPos = this.getPixelPosition(sel.cursor, true); - - var style = (this.cursors[cursorIndex++] || this.addCursor()).style; - - style.left = this.pixelPos.left + "px"; - style.top = this.pixelPos.top + "px"; - style.width = config.characterWidth + "px"; - style.height = config.lineHeight + "px"; - - i++; - } - while (cursorIndex < this.cursors.length) - this.removeCursor(); } var overwrite = this.session.getOverwrite();