aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorNathan Vegdahl2021-07-26 15:50:26 +0000
committerNathan Vegdahl2021-07-26 15:50:26 +0000
commit01247acf0cd06fcb3ba3b033e215b9b13b632816 (patch)
tree9c1ac7b7a61e923e43b5afcdd494c82269acc3ad /helix-term
parent0883b4fae03343978e61fc377775d7ba93f86b40 (diff)
Start searches at the right side of the block cursor.
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/commands.rs20
1 files changed, 5 insertions, 15 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 86ede415..89042acb 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -1024,25 +1024,15 @@ fn split_selection_on_newline(cx: &mut Context) {
}
fn search_impl(doc: &mut Document, view: &mut View, contents: &str, regex: &Regex, extend: bool) {
- let text = doc.text();
+ let text = doc.text().slice(..);
let selection = doc.selection(view.id);
let start = {
+ // Get the right side of the block cursor.
let range = selection.primary();
-
- // This is a little bit weird. Due to 1-width cursor semantics, we
- // would typically want the search to always begin at the visual left-side
- // of the head. However, when there's already a selection from e.g. a
- // previous search result, we don't want to include any of that selection
- // in the subsequent search. The code below makes a compromise between the
- // two behaviors that hopefully behaves the way most people expect most of
- // the time.
- if range.anchor <= range.head {
- text.char_to_byte(range.head)
+ if range.anchor < range.head {
+ range.head
} else {
- text.char_to_byte(graphemes::next_grapheme_boundary(
- text.slice(..),
- range.head,
- ))
+ graphemes::next_grapheme_boundary(text, range.head)
}
};