Implement Action::SelectLine in text::Editor

This commit is contained in:
Héctor Ramón Jiménez 2023-09-14 15:23:20 +02:00
parent f7d66899f1
commit 8cad1d682a
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -334,7 +334,24 @@ impl editor::Editor for Editor {
}
}
}
Action::SelectLine => todo!(),
Action::SelectLine => {
let cursor = editor.cursor();
if let Some(line_length) = editor
.buffer()
.lines
.get(cursor.line)
.map(|line| line.text().len())
{
editor
.set_cursor(cosmic_text::Cursor { index: 0, ..cursor });
editor.set_select_opt(Some(cosmic_text::Cursor {
index: line_length,
..cursor
}));
}
}
// Editing events
Action::Insert(c) => {