editor: typewriter centering keys on view and line heights; a placement resets the editor's centering too
CI / platforms (windows-latest) (push) Failing after 8s
CI / site (push) Successful in 22s
CI / crate (push) Failing after 12m26s
CI / platforms (ubuntu-24.04) (push) Canceled after 0s

This commit is contained in:
ZacharyZhang-NY committed 2026-10-12 09:28:47 -04:00
1 parent cf9cc1971c
commit 7ed4ea8323
4 files changed
+70 -6

No files matched your search

+2 -2
View File
@@ -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
View File
@@ -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)