Added getAWordRange and selectAWord methods
These new methods are necessary to select a word along with its right whitespace, which is a reasonably common scenario.
This commit is contained in:
parent
dbc4a35d38
commit
bb7fd9bb66
2 changed files with 25 additions and 7 deletions
|
|
@ -441,6 +441,17 @@ var EditSession = function(text, mode) {
|
||||||
return new Range(row, start, row, end);
|
return new Range(row, start, row, end);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Gets the range of a word including its right whitespace
|
||||||
|
this.getAWordRange = function(row, column) {
|
||||||
|
var wordRange = this.getWordRange(row, column);
|
||||||
|
var line = this.getLine(wordRange.end.row);
|
||||||
|
|
||||||
|
while (line.charAt(wordRange.end.column).match(/[ \t]/)) {
|
||||||
|
wordRange.end.column += 1;
|
||||||
|
}
|
||||||
|
return wordRange;
|
||||||
|
};
|
||||||
|
|
||||||
this.setNewLineMode = function(newLineMode) {
|
this.setNewLineMode = function(newLineMode) {
|
||||||
this.doc.setNewLineMode(newLineMode);
|
this.doc.setNewLineMode(newLineMode);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -253,6 +253,13 @@ var Selection = function(session) {
|
||||||
this.setSelectionRange(range);
|
this.setSelectionRange(range);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Selects a word including its right whitespace
|
||||||
|
this.selectAWord = function() {
|
||||||
|
var cursor = this.getCursor();
|
||||||
|
var range = this.session.getAWordRange(cursor.row, cursor.column);
|
||||||
|
this.setSelectionRange(range);
|
||||||
|
};
|
||||||
|
|
||||||
this.selectLine = function() {
|
this.selectLine = function() {
|
||||||
var rowStart = this.selectionLead.row;
|
var rowStart = this.selectionLead.row;
|
||||||
var rowEnd;
|
var rowEnd;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue