find and goto must unfold desired locations
This commit is contained in:
parent
d1064ae0e1
commit
d8a8876254
2 changed files with 26 additions and 0 deletions
|
|
@ -415,6 +415,30 @@ function Folding() {
|
|||
}, this);
|
||||
}
|
||||
|
||||
this.unfold = function(location, expandInner) {
|
||||
var range, folds;
|
||||
if (location == null)
|
||||
range = new Range(0, 0, this.getLength(), 0);
|
||||
else if (typeof location == "number")
|
||||
range = new Range(location, 0, location, this.getLine(location).length);
|
||||
else if ("row" in location)
|
||||
range = Range.fromPoints(location, location);
|
||||
else
|
||||
range = location;
|
||||
|
||||
var folds = this.getFoldsInRange(range);
|
||||
if (expandInner) {
|
||||
this.removeFolds(folds);
|
||||
} else {
|
||||
// TODO: might need to remove and add folds in one go instead of using
|
||||
// expandFolds several times.
|
||||
while (folds.length) {
|
||||
this.expandFolds(folds);
|
||||
folds = this.getFoldsInRange(range);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a given documentRow is folded. This is true if there are some
|
||||
* folded parts such that some parts of the line is still visible.
|
||||
|
|
|
|||
|
|
@ -1077,6 +1077,7 @@ var Editor = function(renderer, session) {
|
|||
|
||||
this.gotoLine = function(lineNumber, column) {
|
||||
this.selection.clearSelection();
|
||||
this.session.unfold({row: lineNumber - 1, column: column || 0})
|
||||
|
||||
this.$blockScrolling += 1;
|
||||
this.moveCursorTo(lineNumber-1, column || 0);
|
||||
|
|
@ -1242,6 +1243,7 @@ var Editor = function(renderer, session) {
|
|||
|
||||
var range = this.$search.find(this.session);
|
||||
if (range) {
|
||||
this.session.unfold(range);
|
||||
this.gotoLine(range.end.row+1, range.end.column);
|
||||
this.selection.setSelectionRange(range);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue