summaryrefslogtreecommitdiffstats
path: root/graphics/src/text/editor.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-09-12 18:20:02 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-09-12 18:20:02 +0200
commitabab1448576fbfa4717b65cdf1455debf44f2df5 (patch)
tree88b18dca65fe67c9def93ceb45ea9e835478fae1 /graphics/src/text/editor.rs
parent1455911b636f19810e12eeb12a6eed11c5244cfe (diff)
downloadiced-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.rs13
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()