Make Motion::Home and Motion::End operate on unwrapped lines, fixes #468

This commit is contained in:
Jeremy Soller 2026-02-18 15:39:41 -07:00
parent d7dc22dd20
commit 82fadd954c

View file

@ -1173,17 +1173,7 @@ impl Buffer {
)?; )?;
} }
Motion::Home => { Motion::Home => {
let mut layout_cursor = self.layout_cursor(font_system, cursor)?; cursor.index = 0;
layout_cursor.glyph = 0;
#[allow(unused_assignments)]
{
(cursor, cursor_x_opt) = self.cursor_motion(
font_system,
cursor,
cursor_x_opt,
Motion::LayoutCursor(layout_cursor),
)?;
}
cursor_x_opt = None; cursor_x_opt = None;
} }
Motion::SoftHome => { Motion::SoftHome => {
@ -1196,17 +1186,8 @@ impl Buffer {
cursor_x_opt = None; cursor_x_opt = None;
} }
Motion::End => { Motion::End => {
let mut layout_cursor = self.layout_cursor(font_system, cursor)?; let line = self.lines.get(cursor.line)?;
layout_cursor.glyph = usize::MAX; cursor.index = line.text().len();
#[allow(unused_assignments)]
{
(cursor, cursor_x_opt) = self.cursor_motion(
font_system,
cursor,
cursor_x_opt,
Motion::LayoutCursor(layout_cursor),
)?;
}
cursor_x_opt = None; cursor_x_opt = None;
} }
Motion::ParagraphStart => { Motion::ParagraphStart => {