diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index 4a824832..ec2ef3d1 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -1268,7 +1268,12 @@ var EditSession = function(text, mode) { this.getDocumentLastRowColumn = function(docRow, docColumn) { var screenRow = this.documentToScreenRow(docRow, docColumn); return this.getScreenLastRowColumn(screenRow); - } + }; + + this.getDocumentLastRowColumnPosition = function(docRow, docColumn) { + var screenRow = this.documentToScreenRow(docRow, docColumn); + return this.screenToDocumentPosition(screenRow, Number.MAX_VALUE / 10); + }; this.getRowSplitData = function(row) { if (!this.$useWrapMode) { diff --git a/lib/ace/edit_session/folding.js b/lib/ace/edit_session/folding.js index ec2d16f1..c183bc58 100644 --- a/lib/ace/edit_session/folding.js +++ b/lib/ace/edit_session/folding.js @@ -371,7 +371,22 @@ function Folding() { } }.bind(this), endRow, endColumn); return textLine; - } + }; + + this.getDisplayLine = function(row, endColumn) { + var foldLine = this.getFoldLine(row); + + if (!foldLine) { + if (endColumn == null) { + return this.doc.$lines[row]; + } else { + var line = this.doc.$lines[row]; + return line.substring(endColumn); + } + } else { + return this.getFoldDisplayLine(foldLine, row, endColumn); + } + }; } exports.Folding = Folding; diff --git a/lib/ace/selection.js b/lib/ace/selection.js index a39fdeb0..2a91ff01 100644 --- a/lib/ace/selection.js +++ b/lib/ace/selection.js @@ -247,9 +247,19 @@ var Selection = function(session) { }; this.selectLine = function() { - this.setSelectionAnchor(this.selectionLead.row, 0); + var rowStart = this.selectionLead.row; + var rowEnd; + + var foldLine = this.session.getFoldLine(rowStart); + if (foldLine) { + rowStart = foldLine.start.row; + rowEnd = foldLine.end.row; + } else { + rowEnd = rowStart; + } + this.setSelectionAnchor(rowStart, 0); this.$moveSelection(function() { - this.moveCursorTo(this.selectionLead.row + 1, 0); + this.moveCursorTo(rowEnd + 1, 0); }); }; @@ -310,7 +320,6 @@ var Selection = function(session) { var beforeCursor = this.doc.getLine(row).slice(firstRowColumn, column); var leadingSpace = beforeCursor.match(/^\s*/); if (leadingSpace[0].length == 0) { - var lastRowColumn = this.session.getDocumentLastRowColumn(row, column); leadingSpace = this.doc.getLine(row). substring(firstRowColumn, lastRowColumn). match(/^\s*/); @@ -324,7 +333,12 @@ var Selection = function(session) { this.moveCursorLineEnd = function() { var lead = this.selectionLead; - this.moveCursorTo(lead.row, this.session.getDocumentLastRowColumn(lead.row, lead.column)); + var lastRowColumnPosition = + this.session.getDocumentLastRowColumnPosition(lead.row, lead.column); + this.moveCursorTo( + lastRowColumnPosition.row, + lastRowColumnPosition.column + ); }; this.moveCursorFileEnd = function() {