Add support for folded lines in Selection.selectLine
This commit is contained in:
parent
825cf26478
commit
61fc8d04c4
3 changed files with 40 additions and 6 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue