aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorKirawi2021-06-08 04:20:15 +0000
committerGitHub2021-06-08 04:20:15 +0000
commitb873fb9897bb5b24a60cca3d9fa69285446a857f (patch)
treefe13df2f3f57990f5e6ef93b0049457855d4ed76 /helix-term/src
parent8f1eb7b2b03fd6907307f4e0065d0c43da22edb3 (diff)
Fix Unicode (#135)
* init * wip * wip * fix unicode break * fix unicode break * Update helix-core/src/transaction.rs Co-authored-by: Benoît Cortier <benoit.cortier@fried-world.eu> * clippy * fix * add changes * added test * wip * wip * wip * wip * fix * fix view * fix #88 Co-authored-by: Benoît Cortier <benoit.cortier@fried-world.eu>
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/commands.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 0da23fc7..2412e55d 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -654,9 +654,10 @@ pub fn split_selection_on_newline(cx: &mut Context) {
fn _search(doc: &mut Document, view: &mut View, contents: &str, regex: &Regex, extend: bool) {
let text = doc.text();
let selection = doc.selection(view.id);
- let start = selection.cursor();
+ let start = text.char_to_byte(selection.cursor());
// use find_at to find the next match after the cursor, loop around the end
+ // Careful, `Regex` uses `bytes` as offsets, not character indices!
let mat = regex
.find_at(contents, start)
.or_else(|| regex.find(contents));
@@ -670,7 +671,7 @@ fn _search(doc: &mut Document, view: &mut View, contents: &str, regex: &Regex, e
return;
}
- let head = end;
+ let head = end - 1;
let selection = if extend {
selection.clone().push(Range::new(start, head))
@@ -1027,7 +1028,7 @@ pub fn command_mode(cx: &mut Context) {
let mut prompt = Prompt::new(
":".to_owned(),
|input: &str| {
- // we use .this over split_ascii_whitespace() because we care about empty segments
+ // we use .this over split_whitespace() because we care about empty segments
let parts = input.split(' ').collect::<Vec<&str>>();
// simple heuristic: if there's no just one part, complete command name.
@@ -1069,7 +1070,7 @@ pub fn command_mode(cx: &mut Context) {
return;
}
- let parts = input.split_ascii_whitespace().collect::<Vec<&str>>();
+ let parts = input.split_whitespace().collect::<Vec<&str>>();
if parts.is_empty() {
return;
}