fix: find doesn't change horizontal scroll

fixes #638
This commit is contained in:
Fabian Jakobs 2012-04-06 14:10:40 +02:00
commit 4084931f19
2 changed files with 30 additions and 20 deletions

View file

@ -316,7 +316,11 @@ var Editor = function(renderer, session) {
this.renderer.updateCursor(); this.renderer.updateCursor();
if (!this.$blockScrolling) { if (!this.$blockScrolling) {
this.renderer.scrollCursorIntoView(); var selection = this.getSelection();
if (selection.isEmpty())
this.renderer.scrollCursorIntoView(selection.getCursor());
else
this.renderer.scrollSelectionIntoView(selection.getSelectionLead(), selection.getSelectionAnchor());
} }
// move text input over the cursor // move text input over the cursor

View file

@ -647,12 +647,18 @@ var VirtualRenderer = function(container, theme) {
this.$cursorLayer.showCursor(); this.$cursorLayer.showCursor();
}; };
this.scrollCursorIntoView = function() { this.scrollSelectionIntoView = function(anchor, lead) {
// first scroll anchor into view then scroll lead into view
this.scrollCursorIntoView(anchor);
this.scrollCursorIntoView(lead);
};
this.scrollCursorIntoView = function(cursor) {
// the editor is not visible // the editor is not visible
if (this.$size.scrollerHeight === 0) if (this.$size.scrollerHeight === 0)
return; return;
var pos = this.$cursorLayer.getPixelPosition(); var pos = this.$cursorLayer.getPixelPosition(cursor);
var left = pos.left; var left = pos.left;
var top = pos.top; var top = pos.top;