update tests for word highlighting happening on timeout
This commit is contained in:
parent
6946024526
commit
3e6d6563f1
2 changed files with 23 additions and 3 deletions
|
|
@ -896,10 +896,15 @@ var Editor = function(renderer, session) {
|
|||
return;
|
||||
|
||||
this.$highlightSelectedWord = shouldHighlight;
|
||||
if (shouldHighlight)
|
||||
if (shouldHighlight) {
|
||||
this.session.getMode().highlightSelection(this);
|
||||
else
|
||||
} else {
|
||||
this.session.getMode().clearSelectionHighlight(this);
|
||||
if (this.$wordHighlightTimer) {
|
||||
clearTimeout(this.$wordHighlightTimer);
|
||||
this.$wordHighlightTimer = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -87,6 +87,9 @@ module.exports = {
|
|||
this.editor.moveCursorTo(0, 9);
|
||||
this.selection.selectWord();
|
||||
|
||||
assert.ok(this.editor.$wordHighlightTimer != null);
|
||||
this.session.$mode.highlightSelection(this.editor);
|
||||
|
||||
var range = this.selection.getRange();
|
||||
assert.equal(this.session.getTextRange(range), "ipsum");
|
||||
assert.equal(this.session.$selectionOccurrences.length, 1);
|
||||
|
|
@ -95,6 +98,7 @@ module.exports = {
|
|||
"test: highlight a word and clear highlight": function() {
|
||||
this.editor.moveCursorTo(0, 8);
|
||||
this.selection.selectWord();
|
||||
this.session.$mode.highlightSelection(this.editor);
|
||||
|
||||
var range = this.selection.getRange();
|
||||
assert.equal(this.session.getTextRange(range), "ipsum");
|
||||
|
|
@ -107,6 +111,7 @@ module.exports = {
|
|||
"test: highlight another word": function() {
|
||||
this.selection.moveCursorTo(0, 14);
|
||||
this.selection.selectWord();
|
||||
this.session.$mode.highlightSelection(this.editor);
|
||||
|
||||
var range = this.selection.getRange();
|
||||
assert.equal(this.session.getTextRange(range), "dolor");
|
||||
|
|
@ -115,13 +120,18 @@ module.exports = {
|
|||
|
||||
"test: no selection, no highlight": function() {
|
||||
this.selection.clearSelection();
|
||||
this.session.$mode.highlightSelection(this.editor);
|
||||
assert.equal(this.session.$selectionOccurrences.length, 0);
|
||||
},
|
||||
|
||||
"test: select a word, no highlight": function() {
|
||||
this.editor.setHighlightSelectedWord(false);
|
||||
this.selection.moveCursorTo(0, 14);
|
||||
this.selection.selectWord();
|
||||
this.session.$mode.highlightSelection(this.editor);
|
||||
|
||||
this.editor.setHighlightSelectedWord(false);
|
||||
|
||||
assert.ok(this.editor.$wordHighlightTimer == null);
|
||||
|
||||
var range = this.selection.getRange();
|
||||
assert.equal(this.session.getTextRange(range), "dolor");
|
||||
|
|
@ -146,6 +156,7 @@ module.exports = {
|
|||
this.search.set(currentOptions);
|
||||
|
||||
this.selection.setSelectionRange(match);
|
||||
this.session.$mode.highlightSelection(this.editor);
|
||||
|
||||
assert.equal(this.session.getTextRange(match), "Mauris");
|
||||
assert.equal(this.session.$selectionOccurrences.length, 0);
|
||||
|
|
@ -155,6 +166,7 @@ module.exports = {
|
|||
this.selection.moveCursorTo(0, 14);
|
||||
this.selection.selectWord();
|
||||
this.selection.selectLeft();
|
||||
this.session.$mode.highlightSelection(this.editor);
|
||||
|
||||
var range = this.selection.getRange();
|
||||
assert.equal(this.session.getTextRange(range), "dolo");
|
||||
|
|
@ -165,6 +177,7 @@ module.exports = {
|
|||
this.selection.moveCursorTo(0, 13);
|
||||
this.selection.selectWord();
|
||||
this.selection.selectRight();
|
||||
this.session.$mode.highlightSelection(this.editor);
|
||||
|
||||
var range = this.selection.getRange();
|
||||
assert.equal(this.session.getTextRange(range), "dolor ");
|
||||
|
|
@ -176,6 +189,7 @@ module.exports = {
|
|||
this.selection.selectWord();
|
||||
this.selection.selectLeft();
|
||||
this.selection.shiftSelection(1);
|
||||
this.session.$mode.highlightSelection(this.editor);
|
||||
|
||||
var range = this.selection.getRange();
|
||||
assert.equal(this.session.getTextRange(range), "olor");
|
||||
|
|
@ -202,6 +216,7 @@ module.exports = {
|
|||
this.search.set(currentOptions);
|
||||
|
||||
this.selection.setSelectionRange(match);
|
||||
this.session.$mode.highlightSelection(this.editor);
|
||||
|
||||
assert.equal(this.session.getTextRange(match), "consectetur");
|
||||
assert.equal(this.session.$selectionOccurrences.length, 2);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue