summaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorMichael Davis2022-06-24 13:58:04 +0000
committerGitHub2022-06-24 13:58:04 +0000
commitd948ace67b10f162fd00106b9be2c1c680f33861 (patch)
tree849a5f4778b3b1c6c5253d1e645b0445656a1eb2 /helix-term
parent886cff3bcc5f8e1d81e55afdbbf7ad8ff00ffc7b (diff)
check selection's visible width when copying on mouse click (#2711)
* check selection's visible width when copying on mouse click Mouse-click-up copies the selection produced by dragging. The event is ignored if the selection has a width of 1 though so you don't copy when clicking rather than dragging. The current check copies text when it has a visible width of 1 but is actually multiple characters in the rope like a CRLF line-ending. With this change we check the unicode width of the character(s) in the selection rather than the range length, so clicking on a CRLF line-ending does not copy. * use range.fragment to simplify getting the primary selection width
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/ui/editor.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index debce9b4..70f60070 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -1127,9 +1127,14 @@ impl EditorView {
}
let (view, doc) = current!(cxt.editor);
- let range = doc.selection(view.id).primary();
- if range.to() - range.from() <= 1 {
+ if doc
+ .selection(view.id)
+ .primary()
+ .fragment(doc.text().slice(..))
+ .width()
+ <= 1
+ {
return EventResult::Ignored(None);
}