Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: align view after jumplist_picker #3743

Merged
merged 2 commits into from
Dec 6, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Fix a wrong offset calculation in offset_coords_to_in_view_center
It ignored `scrolloff` if `centering` is false.
  • Loading branch information
shnarazk authored and archseer committed Dec 6, 2022
commit 2625b58e62ec486a84d31cb92fe4492a04bc6f1a
16 changes: 12 additions & 4 deletions helix-view/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,21 @@ impl View {
};
(row, col)
};
let offset_without_centering = new_offset(0);
let current_offset = (self.offset.row, self.offset.col);
if centering {
(offset_without_centering == current_offset).then(|| new_offset(scrolloff))
// return None if cursor is out of view
let offset = new_offset(0);
(offset == current_offset).then(|| {
if scrolloff == 0 {
offset
} else {
new_offset(scrolloff)
}
})
} else {
// TODO: use 'then_some' when 1.62 <= MSRV
(offset_without_centering != current_offset).then(|| offset_without_centering)
// return None if cursor is in (view - scrolloff)
let offset = new_offset(scrolloff);
(offset != current_offset).then(|| offset) // TODO: use 'then_some' when 1.62 <= MSRV
}
}

Expand Down