Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Automatically scroll find selection into view #5861

Merged
merged 2 commits into from
Nov 6, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/search/FindReplace.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ define(function (require, exports, module) {
// no need to scroll if the line with the match is in view
centerOptions = Editor.BOUNDARY_IGNORE_TOP;
}
cm.scrollIntoView({from: cursor.from(), to: cursor.to()});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this always shows selection horizontally, but it cancels the "center vertically" functionality. I see the same results with:

            editor.setSelection(cursor.from(), cursor.to(), false);
            //cm.scrollIntoView({from: cursor.from(), to: cursor.to()});

I think the problem may be that the Editor.centerOnCursor() function passes null as x position to this.setScroll(). Maybe that used to work and there was a change in CodeMirror. Try looking into cm.scrollIntoView() to see what it's doing.

editor.setSelection(cursor.from(), cursor.to(), true, centerOptions);
state.posFrom = cursor.from();
state.posTo = cursor.to();
Expand Down