kopia lustrzana https://github.com/c9/core
fix linewidgets interaction with folding
rodzic
9c91ae4a8c
commit
1ca8dbdd31
|
@ -119,7 +119,7 @@ function Folding() {
|
||||||
var folds = this.getFoldsInRange(ranges);
|
var folds = this.getFoldsInRange(ranges);
|
||||||
}
|
}
|
||||||
return folds;
|
return folds;
|
||||||
}
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns all folds in the document
|
* Returns all folds in the document
|
||||||
|
@ -229,15 +229,15 @@ function Folding() {
|
||||||
end = foldLine.end.row,
|
end = foldLine.end.row,
|
||||||
start = foldLine.start.row;
|
start = foldLine.start.row;
|
||||||
if (end >= last) {
|
if (end >= last) {
|
||||||
if(start < last) {
|
if (start < last) {
|
||||||
if(start >= first)
|
if (start >= first)
|
||||||
rowCount -= last-start;
|
rowCount -= last-start;
|
||||||
else
|
else
|
||||||
rowCount = 0;//in one fold
|
rowCount = 0; // in one fold
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else if(end >= first){
|
} else if (end >= first){
|
||||||
if (start >= first) //fold inside range
|
if (start >= first) // fold inside range
|
||||||
rowCount -= end-start;
|
rowCount -= end-start;
|
||||||
else
|
else
|
||||||
rowCount -= end-first+1;
|
rowCount -= end-first+1;
|
||||||
|
@ -340,7 +340,7 @@ function Folding() {
|
||||||
|
|
||||||
// Notify that fold data has changed.
|
// Notify that fold data has changed.
|
||||||
this.$modified = true;
|
this.$modified = true;
|
||||||
this._emit("changeFold", { data: fold, action: "add" });
|
this._signal("changeFold", { data: fold, action: "add" });
|
||||||
|
|
||||||
return fold;
|
return fold;
|
||||||
};
|
};
|
||||||
|
@ -401,7 +401,7 @@ function Folding() {
|
||||||
|
|
||||||
// Notify that fold data has changed.
|
// Notify that fold data has changed.
|
||||||
this.$modified = true;
|
this.$modified = true;
|
||||||
this._emit("changeFold", { data: fold, action: "remove" });
|
this._signal("changeFold", { data: fold, action: "remove" });
|
||||||
};
|
};
|
||||||
|
|
||||||
this.removeFolds = function(folds) {
|
this.removeFolds = function(folds) {
|
||||||
|
@ -593,7 +593,7 @@ function Folding() {
|
||||||
var placeholder = "...";
|
var placeholder = "...";
|
||||||
if (!range.isMultiLine()) {
|
if (!range.isMultiLine()) {
|
||||||
placeholder = this.getTextRange(range);
|
placeholder = this.getTextRange(range);
|
||||||
if(placeholder.length < 4)
|
if (placeholder.length < 4)
|
||||||
return;
|
return;
|
||||||
placeholder = placeholder.trim().substring(0, 2) + "..";
|
placeholder = placeholder.trim().substring(0, 2) + "..";
|
||||||
}
|
}
|
||||||
|
@ -610,7 +610,7 @@ function Folding() {
|
||||||
if (dir != 1) {
|
if (dir != 1) {
|
||||||
do {
|
do {
|
||||||
token = iterator.stepBackward();
|
token = iterator.stepBackward();
|
||||||
} while(token && re.test(token.type));
|
} while (token && re.test(token.type));
|
||||||
iterator.stepForward();
|
iterator.stepForward();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -622,7 +622,7 @@ function Folding() {
|
||||||
if (dir != -1) {
|
if (dir != -1) {
|
||||||
do {
|
do {
|
||||||
token = iterator.stepForward();
|
token = iterator.stepForward();
|
||||||
} while(token && re.test(token.type));
|
} while (token && re.test(token.type));
|
||||||
token = iterator.stepBackward();
|
token = iterator.stepBackward();
|
||||||
} else
|
} else
|
||||||
token = iterator.getCurrentToken();
|
token = iterator.getCurrentToken();
|
||||||
|
@ -698,7 +698,7 @@ function Folding() {
|
||||||
|
|
||||||
this.off('change', this.$updateFoldWidgets);
|
this.off('change', this.$updateFoldWidgets);
|
||||||
this.off('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets);
|
this.off('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets);
|
||||||
this._emit("changeAnnotation");
|
this._signal("changeAnnotation");
|
||||||
|
|
||||||
if (!foldMode || this.$foldStyle == "manual") {
|
if (!foldMode || this.$foldStyle == "manual") {
|
||||||
this.foldWidgets = null;
|
this.foldWidgets = null;
|
||||||
|
@ -740,7 +740,7 @@ function Folding() {
|
||||||
range: i !== -1 && range,
|
range: i !== -1 && range,
|
||||||
firstRange: firstRange
|
firstRange: firstRange
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
this.onFoldWidgetClick = function(row, e) {
|
this.onFoldWidgetClick = function(row, e) {
|
||||||
e = e.domEvent;
|
e = e.domEvent;
|
||||||
|
@ -752,7 +752,7 @@ function Folding() {
|
||||||
|
|
||||||
var range = this.$toggleFoldWidget(row, options);
|
var range = this.$toggleFoldWidget(row, options);
|
||||||
if (!range) {
|
if (!range) {
|
||||||
var el = (e.target || e.srcElement)
|
var el = (e.target || e.srcElement);
|
||||||
if (el && /ace_fold-widget/.test(el.className))
|
if (el && /ace_fold-widget/.test(el.className))
|
||||||
el.className += " ace_invalid";
|
el.className += " ace_invalid";
|
||||||
}
|
}
|
||||||
|
@ -849,7 +849,7 @@ function Folding() {
|
||||||
if (this.foldWidgets.length > rows.first)
|
if (this.foldWidgets.length > rows.first)
|
||||||
this.foldWidgets.splice(rows.first, this.foldWidgets.length);
|
this.foldWidgets.splice(rows.first, this.foldWidgets.length);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.Folding = Folding;
|
exports.Folding = Folding;
|
||||||
|
|
|
@ -48,6 +48,7 @@ function LineWidgets(session) {
|
||||||
this.$onChangeEditor = this.$onChangeEditor.bind(this);
|
this.$onChangeEditor = this.$onChangeEditor.bind(this);
|
||||||
|
|
||||||
this.session.on("change", this.updateOnChange);
|
this.session.on("change", this.updateOnChange);
|
||||||
|
this.session.on("changeFold", this.updateOnFold);
|
||||||
this.session.on("changeEditor", this.$onChangeEditor);
|
this.session.on("changeEditor", this.$onChangeEditor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,8 +69,8 @@ function LineWidgets(session) {
|
||||||
this.$getWidgetScreenLength = function() {
|
this.$getWidgetScreenLength = function() {
|
||||||
var screenRows = 0;
|
var screenRows = 0;
|
||||||
this.lineWidgets.forEach(function(w){
|
this.lineWidgets.forEach(function(w){
|
||||||
if (w && w.rowCount)
|
if (w && w.rowCount && !w.hidden)
|
||||||
screenRows +=w.rowCount;
|
screenRows += w.rowCount;
|
||||||
});
|
});
|
||||||
return screenRows;
|
return screenRows;
|
||||||
};
|
};
|
||||||
|
@ -113,6 +114,32 @@ function LineWidgets(session) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.updateOnFold = function(e, session) {
|
||||||
|
var lineWidgets = session.lineWidgets;
|
||||||
|
if (!lineWidgets || !e.action)
|
||||||
|
return;
|
||||||
|
var fold = e.data;
|
||||||
|
var start = fold.start.row;
|
||||||
|
var end = fold.end.row;
|
||||||
|
var hide = e.action == "add";
|
||||||
|
for (var i = start + 1; i < end; i++) {
|
||||||
|
if (lineWidgets[i])
|
||||||
|
lineWidgets[i].hidden = hide;
|
||||||
|
}
|
||||||
|
if (lineWidgets[end]) {
|
||||||
|
if (hide) {
|
||||||
|
if (!lineWidgets[start])
|
||||||
|
lineWidgets[start] = lineWidgets[end];
|
||||||
|
else
|
||||||
|
lineWidgets[end].hidden = hide;
|
||||||
|
} else {
|
||||||
|
if (lineWidgets[start] == lineWidgets[end])
|
||||||
|
lineWidgets[start] = undefined;
|
||||||
|
lineWidgets[end].hidden = hide;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
this.updateOnChange = function(delta) {
|
this.updateOnChange = function(delta) {
|
||||||
var lineWidgets = this.session.lineWidgets;
|
var lineWidgets = this.session.lineWidgets;
|
||||||
if (!lineWidgets) return;
|
if (!lineWidgets) return;
|
||||||
|
@ -175,9 +202,22 @@ function LineWidgets(session) {
|
||||||
if (!w.pixelHeight) {
|
if (!w.pixelHeight) {
|
||||||
w.pixelHeight = w.el.offsetHeight;
|
w.pixelHeight = w.el.offsetHeight;
|
||||||
}
|
}
|
||||||
if (w.rowCount == null)
|
if (w.rowCount == null) {
|
||||||
w.rowCount = w.pixelHeight / renderer.layerConfig.lineHeight;
|
w.rowCount = w.pixelHeight / renderer.layerConfig.lineHeight;
|
||||||
|
}
|
||||||
|
if (w.fullWidth) {
|
||||||
|
w.pixelWidth = w.el.pixelWidth;
|
||||||
|
}
|
||||||
|
var fold = this.session.getFoldAt(w.row, 0);
|
||||||
|
w.$fold = fold;
|
||||||
|
if (fold) {
|
||||||
|
var lineWidgets = this.session.lineWidgets;
|
||||||
|
if (w.row == fold.end.row && !lineWidgets[fold.start.row])
|
||||||
|
lineWidgets[fold.start.row] = w;
|
||||||
|
else
|
||||||
|
w.hidden = true;
|
||||||
|
}
|
||||||
|
|
||||||
this.session._emit("changeFold", {data:{start:{row: w.row}}});
|
this.session._emit("changeFold", {data:{start:{row: w.row}}});
|
||||||
|
|
||||||
this.$updateRows();
|
this.$updateRows();
|
||||||
|
@ -260,7 +300,10 @@ function LineWidgets(session) {
|
||||||
for (var i = first; i <= last; i++) {
|
for (var i = first; i <= last; i++) {
|
||||||
var w = lineWidgets[i];
|
var w = lineWidgets[i];
|
||||||
if (!w || !w.el) continue;
|
if (!w || !w.el) continue;
|
||||||
|
if (w.hidden) {
|
||||||
|
w.el.style.top = -100 - (w.pixelHeight || 0) + "px";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!w._inDocument) {
|
if (!w._inDocument) {
|
||||||
w._inDocument = true;
|
w._inDocument = true;
|
||||||
renderer.container.appendChild(w.el);
|
renderer.container.appendChild(w.el);
|
||||||
|
|
Ładowanie…
Reference in New Issue