editor: typewriter centering keys on view and line heights; a placement resets the editor's centering too
This commit is contained in:
4 files changed
+70
-6
No files matched your search
+2
-2
@@ -122,8 +122,8 @@ pub struct CodeEditor {
|
||||
/// The text before an input method's composition began, while it runs.
|
||||
pub(crate) composing: Option<Snapshot>,
|
||||
pub(crate) metrics: Metrics,
|
||||
/// The caret row typewriter scrolling last centered.
|
||||
pub(crate) centered: Option<usize>,
|
||||
/// The caret row, view and line heights last centered.
|
||||
pub(crate) centered: Option<(usize, Pixels, Pixels)>,
|
||||
/// Typewriter room rows at each end.
|
||||
pub(crate) pad: usize,
|
||||
pub(crate) dragging: bool,
|
||||
|
||||
+4
-4
@@ -272,11 +272,11 @@ impl Render for CodeEditor {
|
||||
self.metrics.advance = advance;
|
||||
self.metrics.line = line;
|
||||
// Typewriter: the caret's row centers as it moves.
|
||||
let row = self.primary_row();
|
||||
if self.options.typewriter && self.centered != Some(row) {
|
||||
let centered = (self.primary_row(), self.metrics.height, line);
|
||||
if self.options.typewriter && self.centered != Some(centered) {
|
||||
self.scroll
|
||||
.scroll_to_item_strict(row, ScrollStrategy::Center);
|
||||
self.centered = Some(row);
|
||||
.scroll_to_item_strict(centered.0, ScrollStrategy::Center);
|
||||
self.centered = Some(centered);
|
||||
}
|
||||
let sticky = if self.options.sticky {
|
||||
self.sticky(cx)
|
||||
|
||||
Reference in new issue
Block a user