From 1ac4ea51e2718f9ba97148a1a44ac5db4f8f71a0 Mon Sep 17 00:00:00 2001 From: nightwing Date: Mon, 26 Aug 2013 22:52:40 +0400 Subject: [PATCH] hack edit session --- lib/ace/edit_session.js | 28 ++++++++++++++++++++++++++++ lib/ace/selection.js | 5 +++++ 2 files changed, 33 insertions(+) diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index 98c1e940..260baa5e 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -1037,8 +1037,20 @@ var EditSession = function(text, mode) { **/ this.getScreenWidth = function() { this.$computeWidth(); + if (this.lineWidgets) + return Math.max(this.getLineWidgetMaxWidth(), this.screenWidth); return this.screenWidth; }; + + this.getLineWidgetMaxWidth = function() { + if (this.lineWidgetsWidth != null) return this.lineWidgetsWidth + var width = 0; + this.lineWidgets.forEach(function(w) { + if (w && w.screenWidth > width) + width = w.screenWidth; + }); + return this.lineWidgetWidth = width; + } this.$computeWidth = function(force) { if (this.$modified || force) { @@ -2043,6 +2055,7 @@ var EditSession = function(text, mode) { return [screenColumn, column]; }; + this.lineWidgets = null; /** * Returns number of screenrows in a wrapped line. * @param {Number} row The row number to check @@ -2050,6 +2063,17 @@ var EditSession = function(text, mode) { * @returns {Number} **/ this.getRowLength = function(row) { + if (this.lineWidgets) + var h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0; + else + h = 0 + if (!this.$useWrapMode || !this.$wrapData[row]) { + return 1 + h; + } else { + return this.$wrapData[row].length + 1 + h; + } + }; + this.getRowLineCount = function(row) { if (!this.$useWrapMode || !this.$wrapData[row]) { return 1; } else { @@ -2372,6 +2396,10 @@ var EditSession = function(text, mode) { } } + // todo + if (this.lineWidgets) + screenRows += this.$getWidgetScreenLength(); + return screenRows; }; diff --git a/lib/ace/selection.js b/lib/ace/selection.js index d3dab831..f249f3e0 100644 --- a/lib/ace/selection.js +++ b/lib/ace/selection.js @@ -783,6 +783,11 @@ var Selection = function(session) { } var docPos = this.session.screenToDocumentPosition(screenPos.row + rows, screenPos.column); + + if (rows != 0 && chars == 0 && docPos.row == screenPos.row && docPos.column == screenPos.column) { + if (this.session.lineWidgets && this.session.lineWidgets[docPos.row]) + docPos.row++; + } // move the cursor and update the desired column this.moveCursorTo(docPos.row, docPos.column + chars, chars === 0);