Make sure the current search needle is not lost.
This commit is contained in:
parent
b6e136201d
commit
24e1357755
1 changed files with 7 additions and 5 deletions
|
|
@ -74,7 +74,7 @@ var Editor =function(renderer, session) {
|
|||
this.$selectionMarker = null;
|
||||
this.$highlightLineMarker = null;
|
||||
this.$blockScrolling = 0;
|
||||
this.$selectedWordMarkers = [];
|
||||
this.$selectionOccurrences = [];
|
||||
|
||||
this.$search = new Search().set({
|
||||
wrap: true
|
||||
|
|
@ -237,7 +237,7 @@ var Editor =function(renderer, session) {
|
|||
};
|
||||
|
||||
this.highlightSelection = function() {
|
||||
if (this.$selectedWordMarkers.length)
|
||||
if (this.$selectionOccurrences.length)
|
||||
this.clearSelectionHighlight();
|
||||
|
||||
var selectedRange = this.getSelectionRange();
|
||||
|
|
@ -253,15 +253,17 @@ var Editor =function(renderer, session) {
|
|||
this.$search.set(newOptions);
|
||||
|
||||
var ranges = this.$search.findAll(this.session);
|
||||
this.$selectedWordMarkers = [];
|
||||
this.$selectionOccurrences = [];
|
||||
ranges.forEach(function(range) {
|
||||
if (!range.contains(selectedRange.start.row, selectedRange.start.column))
|
||||
this.$selectedWordMarkers.push(this.renderer.addMarker(range, "ace_selected_word"));
|
||||
this.$selectionOccurrences.push(this.renderer.addMarker(range, "ace_selected_word"));
|
||||
}, this);
|
||||
|
||||
this.$search.set(currentOptions);
|
||||
};
|
||||
|
||||
this.clearSelectionHighlight = function() {
|
||||
this.$selectedWordMarkers.forEach(function(marker) {
|
||||
this.$selectionOccurrences.forEach(function(marker) {
|
||||
this.renderer.removeMarker(marker);
|
||||
}, this);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue