Fix scroll-to-the-middle bug.

(imported from commit dcd102541c8ee2b341060def714c24b05f2db514)
This commit is contained in:
Steve Howell 2013-07-08 22:54:23 -04:00
parent cf710708df
commit 1edd9a1d9f
1 changed files with 10 additions and 4 deletions

View File

@ -422,12 +422,18 @@ exports.activate = function (operators, opts) {
});
}
var manual_scroll = narrowed_msg_list.get(then_select_id) !== undefined;
narrowed_msg_list.select_id(then_select_id, {then_scroll: !manual_scroll,
var preserve_pre_narrowing_screen_position =
!opts.select_first_unread &&
(narrowed_msg_list.get(then_select_id) !== undefined) &&
(then_select_offset !== undefined);
var then_scroll = !preserve_pre_narrowing_screen_position;
narrowed_msg_list.select_id(then_select_id, {then_scroll: then_scroll,
use_closest: true,
mark_read: false});
if (! opts.select_first_unread && then_select_offset !== undefined &&
manual_scroll) {
if (preserve_pre_narrowing_screen_position) {
// Scroll so that the selected message is in the same
// position in the viewport as it was prior to
// narrowing