reduce flickering of annotations while editing
This commit is contained in:
parent
828e445a27
commit
b44bcb50ce
1 changed files with 22 additions and 0 deletions
|
|
@ -44,6 +44,7 @@ var Gutter = function(parentEl) {
|
|||
this.gutterWidth = 0;
|
||||
|
||||
this.$annotations = [];
|
||||
this.$updateAnnotations = this.$updateAnnotations.bind(this);
|
||||
};
|
||||
|
||||
(function() {
|
||||
|
|
@ -51,7 +52,10 @@ var Gutter = function(parentEl) {
|
|||
oop.implement(this, EventEmitter);
|
||||
|
||||
this.setSession = function(session) {
|
||||
if (this.session)
|
||||
this.session.removeEventListener("change", this.$updateAnnotations);
|
||||
this.session = session;
|
||||
session.on("change", this.$updateAnnotations);
|
||||
};
|
||||
|
||||
this.addGutterDecoration = function(row, className){
|
||||
|
|
@ -93,6 +97,24 @@ var Gutter = function(parentEl) {
|
|||
}
|
||||
};
|
||||
|
||||
this.$updateAnnotations = function (e) {
|
||||
if (!this.$annotations.length)
|
||||
return;
|
||||
var delta = e.data;
|
||||
var range = delta.range;
|
||||
var firstRow = range.start.row;
|
||||
var len = range.end.row - firstRow;
|
||||
if (len === 0) {
|
||||
// do nothing
|
||||
} else if (delta.action == "removeText" || delta.action == "removeLines") {
|
||||
this.$annotations.splice(firstRow, len + 1, null);
|
||||
} else {
|
||||
var args = Array(len + 1);
|
||||
args.unshift(firstRow, 1);
|
||||
this.$annotations.splice.apply(this.$annotations, args);
|
||||
}
|
||||
};
|
||||
|
||||
this.update = function(config) {
|
||||
var emptyAnno = {className: ""};
|
||||
var html = [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue