fix #505
This commit is contained in:
parent
392a80d23c
commit
be69263d31
4 changed files with 32 additions and 2 deletions
|
|
@ -393,7 +393,7 @@ var EditSession = function(text, mode) {
|
|||
};
|
||||
|
||||
this.getAnnotations = function() {
|
||||
return this.$annotations;
|
||||
return this.$annotations || {};
|
||||
};
|
||||
|
||||
this.clearAnnotations = function() {
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@ var EditSession = require("./edit_session").EditSession;
|
|||
var Editor = require("./editor").Editor;
|
||||
var Text = require("./mode/text").Mode;
|
||||
var JavaScriptMode = require("./mode/javascript").Mode;
|
||||
var CssMode = require("./mode/css").Mode;
|
||||
var HtmlMode = require("./mode/html").Mode;
|
||||
var MockRenderer = require("./test/mockrenderer").MockRenderer;
|
||||
var assert = require("./test/assertions");
|
||||
|
||||
|
|
@ -157,6 +159,31 @@ module.exports = {
|
|||
|
||||
this.session2.setMode(new JavaScriptMode());
|
||||
assert.ok(called);
|
||||
},
|
||||
|
||||
"test: should use stop worker of old document" : function(next) {
|
||||
var self = this;
|
||||
|
||||
// 1. Open an editor and set the session to CssMode
|
||||
self.editor.setSession(self.session1);
|
||||
self.session1.setMode(new CssMode());
|
||||
|
||||
// 2. Add a line or two of valid CSS.
|
||||
self.session1.setValue("DIV { color: red; }");
|
||||
|
||||
// 3. Clear the session value.
|
||||
self.session1.setValue("");
|
||||
|
||||
// 4. Set the session to HtmlMode
|
||||
self.session1.setMode(new HtmlMode());
|
||||
|
||||
// 5. Try to type valid HTML
|
||||
self.session1.insert({row: 0, column: 0}, "<html></html>");
|
||||
|
||||
setTimeout(function() {
|
||||
assert.equal(Object.keys(self.session1.getAnnotations()).length, 0);
|
||||
next();
|
||||
}, 600);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -106,7 +106,9 @@ oop.inherits(Mode, TextMode);
|
|||
|
||||
worker.on("ok", function(e) {
|
||||
session.clearAnnotations();
|
||||
});
|
||||
});
|
||||
|
||||
return worker;
|
||||
};
|
||||
|
||||
}).call(Mode.prototype);
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ oop.inherits(Mode, TextMode);
|
|||
|
||||
session.setAnnotations(errors);
|
||||
});
|
||||
return worker;
|
||||
};
|
||||
|
||||
}).call(Mode.prototype);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue