find and undo must center selection into view
This commit is contained in:
parent
6799599306
commit
621c7c3dc8
2 changed files with 18 additions and 12 deletions
|
|
@ -982,7 +982,7 @@ var Editor = function(renderer, session) {
|
||||||
this.renderer.animateScrolling(function() {
|
this.renderer.animateScrolling(function() {
|
||||||
renderer.scrollBy(0, rows * config.lineHeight);
|
renderer.scrollBy(0, rows * config.lineHeight);
|
||||||
if (select != null)
|
if (select != null)
|
||||||
renderer.scrollCursorIntoView();
|
renderer.scrollCursorIntoView(null, 0.5);
|
||||||
}, this);
|
}, this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1262,17 +1262,23 @@ var Editor = function(renderer, session) {
|
||||||
this.$blockScrolling -= 1;
|
this.$blockScrolling -= 1;
|
||||||
|
|
||||||
this.renderer.animateScrolling(function() {
|
this.renderer.animateScrolling(function() {
|
||||||
this.renderer.scrollSelectionIntoView(range.start, range.end);
|
this.renderer.scrollSelectionIntoView(range.start, range.end, 0.5);
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.undo = function() {
|
this.undo = function() {
|
||||||
|
this.$blockScrolling++;
|
||||||
this.session.getUndoManager().undo();
|
this.session.getUndoManager().undo();
|
||||||
|
this.$blockScrolling--;
|
||||||
|
renderer.scrollCursorIntoView(null, 0.5);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.redo = function() {
|
this.redo = function() {
|
||||||
|
this.$blockScrolling++;
|
||||||
this.session.getUndoManager().redo();
|
this.session.getUndoManager().redo();
|
||||||
|
this.$blockScrolling--;
|
||||||
|
renderer.scrollCursorIntoView(null, 0.5);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.destroy = function() {
|
this.destroy = function() {
|
||||||
|
|
|
||||||
|
|
@ -678,13 +678,13 @@ var VirtualRenderer = function(container, theme) {
|
||||||
this.$cursorLayer.showCursor();
|
this.$cursorLayer.showCursor();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.scrollSelectionIntoView = function(anchor, lead) {
|
this.scrollSelectionIntoView = function(anchor, lead, offset) {
|
||||||
// first scroll anchor into view then scroll lead into view
|
// first scroll anchor into view then scroll lead into view
|
||||||
this.scrollCursorIntoView(anchor);
|
this.scrollCursorIntoView(anchor, offset);
|
||||||
this.scrollCursorIntoView(lead);
|
this.scrollCursorIntoView(lead, offset);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.scrollCursorIntoView = function(cursor) {
|
this.scrollCursorIntoView = function(cursor, offset) {
|
||||||
// the editor is not visible
|
// the editor is not visible
|
||||||
if (this.$size.scrollerHeight === 0)
|
if (this.$size.scrollerHeight === 0)
|
||||||
return;
|
return;
|
||||||
|
|
@ -695,10 +695,12 @@ var VirtualRenderer = function(container, theme) {
|
||||||
var top = pos.top;
|
var top = pos.top;
|
||||||
|
|
||||||
if (this.scrollTop > top) {
|
if (this.scrollTop > top) {
|
||||||
|
if (offset)
|
||||||
|
top -= offset * this.$size.scrollerHeight;
|
||||||
this.session.setScrollTop(top);
|
this.session.setScrollTop(top);
|
||||||
}
|
} else if (this.scrollTop + this.$size.scrollerHeight < top + this.lineHeight) {
|
||||||
|
if (offset)
|
||||||
if (this.scrollTop + this.$size.scrollerHeight < top + this.lineHeight) {
|
top += offset * this.$size.scrollerHeight;
|
||||||
this.session.setScrollTop(top + this.lineHeight - this.$size.scrollerHeight);
|
this.session.setScrollTop(top + this.lineHeight - this.$size.scrollerHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -708,9 +710,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
if (left < this.$padding + 2 * this.layerConfig.characterWidth)
|
if (left < this.$padding + 2 * this.layerConfig.characterWidth)
|
||||||
left = 0;
|
left = 0;
|
||||||
this.session.setScrollLeft(left);
|
this.session.setScrollLeft(left);
|
||||||
}
|
} else if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) {
|
||||||
|
|
||||||
if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) {
|
|
||||||
this.session.setScrollLeft(Math.round(left + this.characterWidth - this.$size.scrollerWidth));
|
this.session.setScrollLeft(Math.round(left + this.characterWidth - this.$size.scrollerWidth));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue