fix highlighting stopping randomly in the middle of the file
This commit is contained in:
parent
0abd9ec30e
commit
fa86327b3d
2 changed files with 45 additions and 3 deletions
|
|
@ -68,11 +68,10 @@ var BackgroundTokenizer = function(tokenizer, editor) {
|
||||||
var endLine = -1;
|
var endLine = -1;
|
||||||
var doc = self.doc;
|
var doc = self.doc;
|
||||||
|
|
||||||
|
var startLine = currentLine;
|
||||||
while (self.lines[currentLine])
|
while (self.lines[currentLine])
|
||||||
currentLine++;
|
currentLine++;
|
||||||
|
|
||||||
var startLine = currentLine;
|
|
||||||
|
|
||||||
var len = doc.getLength();
|
var len = doc.getLength();
|
||||||
var processedLines = 0;
|
var processedLines = 0;
|
||||||
self.running = false;
|
self.running = false;
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,49 @@ module.exports = {
|
||||||
|
|
||||||
forceTokenize(doc)
|
forceTokenize(doc)
|
||||||
testStates(doc, ["comment_regex_allowed", "start", "no_regex"])
|
testStates(doc, ["comment_regex_allowed", "start", "no_regex"])
|
||||||
|
},
|
||||||
|
"test background tokenizer sends update event" : function() {
|
||||||
|
var doc = new EditSession([
|
||||||
|
"/*",
|
||||||
|
"var",
|
||||||
|
"juhu",
|
||||||
|
"*/"
|
||||||
|
]);
|
||||||
|
doc.setMode("./mode/javascript");
|
||||||
|
|
||||||
|
var updateEvent = null;
|
||||||
|
doc.bgTokenizer.on("update", function(e) {
|
||||||
|
updateEvent = e.data;
|
||||||
|
});
|
||||||
|
function checkEvent(first, last) {
|
||||||
|
assert.ok(!updateEvent, "unneccessary update event");
|
||||||
|
doc.bgTokenizer.running = 1;
|
||||||
|
doc.bgTokenizer.$worker();
|
||||||
|
assert.ok(updateEvent);
|
||||||
|
assert.equal([first, last] + "",
|
||||||
|
[updateEvent.first, updateEvent.last] + "")
|
||||||
|
updateEvent = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
forceTokenize(doc);
|
||||||
|
var comment = "comment_regex_allowed";
|
||||||
|
testStates(doc, [comment, comment, comment, "start"]);
|
||||||
|
|
||||||
|
doc.remove(new Range(0,0,0,2));
|
||||||
|
testStates(doc, [comment, comment, comment, "start"]);
|
||||||
|
|
||||||
|
checkEvent(0, 3);
|
||||||
|
testStates(doc, ["start", "no_regex", "no_regex", "regex"]);
|
||||||
|
|
||||||
|
// insert /* and and press down several times quickly
|
||||||
|
doc.insert({row:0, column:0}, "/*");
|
||||||
|
doc.getTokens(0);
|
||||||
|
doc.getTokens(1);
|
||||||
|
doc.getTokens(2);
|
||||||
|
checkEvent(0, 3);
|
||||||
|
|
||||||
|
forceTokenize(doc);
|
||||||
|
testStates(doc, [comment, comment, comment, "start"]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue