From 61ee50c73c399e12b1d1846bfc40a0dffa017569 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Sun, 14 Jul 2024 19:18:58 +0200 Subject: [PATCH] Fix `SelectAll` action in `editor` --- graphics/src/text/editor.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/graphics/src/text/editor.rs b/graphics/src/text/editor.rs index 0956447a95..afe901d752 100644 --- a/graphics/src/text/editor.rs +++ b/graphics/src/text/editor.rs @@ -309,7 +309,8 @@ impl editor::Editor for Editor { editor.set_selection(cosmic_text::Selection::Line(cursor)); } Action::SelectAll => { - let buffer = editor.buffer(); + let buffer = buffer_from_editor(editor); + if buffer.lines.len() > 1 || buffer .lines @@ -317,15 +318,20 @@ impl editor::Editor for Editor { .is_some_and(|line| !line.text().is_empty()) { let cursor = editor.cursor(); - editor.set_select_opt(Some(cosmic_text::Cursor { - line: 0, - index: 0, - ..cursor - })); + + editor.set_selection(cosmic_text::Selection::Normal( + cosmic_text::Cursor { + line: 0, + index: 0, + ..cursor + }, + )); editor.action( font_system.raw(), - motion_to_action(Motion::DocumentEnd), + cosmic_text::Action::Motion( + cosmic_text::Motion::BufferEnd, + ), ); } }