diff options
author | 2023-09-12 18:20:02 +0200 | |
---|---|---|
committer | 2023-09-12 18:20:02 +0200 | |
commit | abab1448576fbfa4717b65cdf1455debf44f2df5 (patch) | |
tree | 88b18dca65fe67c9def93ceb45ea9e835478fae1 /graphics/src/text/editor.rs | |
parent | 1455911b636f19810e12eeb12a6eed11c5244cfe (diff) | |
download | iced-abab1448576fbfa4717b65cdf1455debf44f2df5.tar.gz iced-abab1448576fbfa4717b65cdf1455debf44f2df5.tar.bz2 iced-abab1448576fbfa4717b65cdf1455debf44f2df5.zip |
Return `Cursor::Caret` if selection matches cursor position in `Editor::cursor`
Diffstat (limited to 'graphics/src/text/editor.rs')
-rw-r--r-- | graphics/src/text/editor.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/graphics/src/text/editor.rs b/graphics/src/text/editor.rs index b4d6819f..7b0ddec1 100644 --- a/graphics/src/text/editor.rs +++ b/graphics/src/text/editor.rs @@ -72,15 +72,18 @@ impl editor::Editor for Editor { fn cursor(&self) -> editor::Cursor { let internal = self.internal(); + let cursor = internal.editor.cursor(); + let buffer = internal.editor.buffer(); + match internal.editor.select_opt() { - Some(selection) => { + Some(selection) + if cursor.line != selection.line + || cursor.index != selection.index => + { // TODO Cursor::Selection(vec![]) } - None => { - let cursor = internal.editor.cursor(); - let buffer = internal.editor.buffer(); - + _ => { let lines_before_cursor: usize = buffer .lines .iter() |