Permalink
Browse files

Merge pull request #602 from nightwing/pullreq

bugfix
  • Loading branch information...
fjakobs committed Jan 2, 2012
2 parents 73dd10a + 496446d commit c1a8d2a1dc14408f799e8b06d6cfa789a4bd9102
@@ -263,6 +263,11 @@ exports.commands = [{
bindKey: bindKey("Ctrl-Shift-E", "Command-Shift-E"),
exec: function(editor) { editor.commands.replay(editor); },
readOnly: true
+}, {
+ name: "jumptomatching",
+ bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"),
+ exec: function(editor) { editor.jumpToMatching(); },
+ readOnly: true
},
// commands disabled in readOnly mode
@@ -381,10 +386,6 @@ exports.commands = [{
name: "tolowercase",
bindKey: bindKey("Ctrl-Shift-U", "Ctrl-Shift-U"),
exec: function(editor) { editor.toLowerCase(); }
-}, {
- name: "jumptomatching",
- bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"),
- exec: function(editor) { editor.jumpToMatching(); }
}];
});
@@ -625,7 +625,7 @@ function Folding() {
this.foldAll = function(startRow, endRow) {
var foldWidgets = this.foldWidgets;
- endRow = endRow || foldWidgets.length;
+ endRow = endRow || this.getLength();
for (var row = startRow || 0; row < endRow; row++) {
if (foldWidgets[row] == null)
foldWidgets[row] = this.getFoldWidget(row);
View
@@ -221,6 +221,7 @@ var Editor = function(renderer, session) {
this.setFontSize = function(size) {
this.container.style.fontSize = size;
+ this.renderer.updateFontSize();
};
this.$highlightBrackets = function() {
@@ -1205,8 +1206,7 @@ var Editor = function(renderer, session) {
var range = this.$search.find(this.session);
if (range) {
this.session.unfold(range);
- this.gotoLine(range.end.row+1, range.end.column);
- this.selection.setSelectionRange(range);
+ this.selection.setSelectionRange(range); // this scrolls selection into view
}
};
View
@@ -93,15 +93,16 @@ var Cursor = function(parentEl) {
}, 1000);
};
- this.getPixelPosition = function(onScreen) {
+ this.getPixelPosition = function(position, onScreen) {
if (!this.config || !this.session) {
return {
left : 0,
top : 0
};
}
- var position = this.session.selection.getCursor();
+ if (!position)
+ position = this.session.selection.getCursor();
var pos = this.session.documentToScreenPosition(position);
var cursorLeft = Math.round(this.$padding +
pos.column * this.config.characterWidth);
@@ -117,7 +118,7 @@ var Cursor = function(parentEl) {
this.update = function(config) {
this.config = config;
- this.pixelPos = this.getPixelPosition(true);
+ this.pixelPos = this.getPixelPosition(null, true);
this.cursor.style.left = this.pixelPos.left + "px";
this.cursor.style.top = this.pixelPos.top + "px";
View
@@ -84,7 +84,7 @@ var Text = function(parentEl) {
var size = this.$measureSizes();
if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) {
this.$characterSize = size;
- this._emit("changeCharaterSize", {data: size});
+ this._emit("changeCharacterSize", {data: size});
}
};
View
@@ -117,6 +117,8 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
var range = delta.range;
if(range.start.row !== range.end.row) return;
if(range.start.row !== this.pos.row) return;
+ if (this.$updating) return;
+ this.$updating = true;
var lengthDiff = delta.action === "insertText" ? range.end.column - range.start.column : range.start.column - range.end.column;
if(range.start.column >= this.pos.column && range.start.column <= this.pos.column + this.length + 1) {
@@ -169,9 +171,11 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
this.others[i]._emit("change", {value: this.others[i]});
}
}
+ this.$updating = false;
};
this.onCursorChange = function(event) {
+ if (this.$updating) return;
var pos = this.session.selection.getCursor();
if(pos.row === this.pos.row && pos.column >= this.pos.column && pos.column <= this.pos.column + this.length) {
this.showOtherMarkers();
@@ -118,7 +118,7 @@ var VirtualRenderer = function(container, theme) {
column : 0
};
- this.$textLayer.addEventListener("changeCharaterSize", function() {
+ this.$textLayer.addEventListener("changeCharacterSize", function() {
_self.characterWidth = textLayer.getCharacterWidth();
_self.lineHeight = textLayer.getLineHeight();
_self.$updatePrintMargin();
@@ -171,6 +171,7 @@ var VirtualRenderer = function(container, theme) {
this.CHANGE_MARKER_BACK = 128;
this.CHANGE_MARKER_FRONT = 256;
this.CHANGE_FULL = 512;
+ this.CHANGE_H_SCROLL = 1024;
oop.implement(this, EventEmitter);
@@ -476,6 +477,11 @@ var VirtualRenderer = function(container, theme) {
if (changes & this.CHANGE_SIZE)
this.$updateScrollBar();
+
+ if (changes & this.CHANGE_H_SCROLL) {
+ //this.content.style.left = -this.scrollLeft + "px";
+ this.scroller.scrollLeft = this.scrollLeft
+ }
};
this.$computeLayerConfig = function() {
@@ -542,12 +548,6 @@ var VirtualRenderer = function(container, theme) {
this.content.style.width = longestLine + 2 * this.$padding + "px";
this.content.style.height = minHeight + "px";
- // scroller.scrollWidth was smaller than scrollLeft we needed
- if (this.$desiredScrollLeft) {
- this.scrollToX(this.$desiredScrollLeft);
- this.$desiredScrollLeft = 0;
- }
-
// Horizontal scrollbar visibility may have changed, which changes
// the client height of the scroller
if (horizScrollChanged)
@@ -653,14 +653,11 @@ var VirtualRenderer = function(container, theme) {
if (scrollLeft > left) {
if (left < this.$padding + 2 * this.layerConfig.characterWidth)
left = 0;
- this.scrollToX(left);
+ this.session.setScrollLeft(left);
}
if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) {
- if (left > this.layerConfig.width + 2 * this.$padding)
- this.$desiredScrollLeft = left;
- else
- this.scrollToX(Math.round(left + this.characterWidth - this.$size.scrollerWidth));
+ this.session.setScrollLeft(Math.round(left + this.characterWidth - this.$size.scrollerWidth));
}
};
@@ -685,15 +682,11 @@ var VirtualRenderer = function(container, theme) {
};
this.scrollToLine = function(line, center) {
- var lineHeight = { lineHeight: this.lineHeight };
- var offset = 0;
- for (var l = 1; l < line; l++) {
- offset += this.session.getRowHeight(lineHeight, l-1);
- }
-
- if (center) {
+ var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
+ var offset = pos.top;
+ if (center)
offset -= this.$size.scrollerHeight / 2;
- }
+
this.session.setScrollTop(offset);
};
@@ -710,8 +703,10 @@ var VirtualRenderer = function(container, theme) {
if (scrollLeft <= this.$padding)
scrollLeft = 0;
- this.scroller.scrollLeft = scrollLeft;
- scrollLeft = this.scroller.scrollLeft;
+ if (this.scrollLeft !== scrollLeft) {
+ this.$loop.schedule(this.CHANGE_H_SCROLL);
+ this.scrollLeft = scrollLeft;
+ }
};
this.scrollBy = function(deltaX, deltaY) {

0 comments on commit c1a8d2a

Please sign in to comment.