Skip to content

Commit

Permalink
fix: backspace --under didn't map UTF-8 character code points to by…
Browse files Browse the repository at this point in the history
…te indices (#2010)
  • Loading branch information
sxyazi authored Dec 7, 2024
1 parent 8ec944d commit 6308873
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion yazi-core/src/input/commands/backspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl Input {
let snap = self.snaps.current_mut();
if !opt.under && snap.cursor < 1 {
return;
} else if opt.under && snap.cursor >= snap.value.len() {
} else if opt.under && snap.cursor >= snap.count() {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion yazi-core/src/input/commands/complete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl Input {
return;
}

let delta = new.chars().count() as isize - snap.value.chars().count() as isize;
let delta = new.chars().count() as isize - snap.count() as isize;
snap.value = new;

self.move_(delta);
Expand Down
2 changes: 1 addition & 1 deletion yazi-core/src/input/snap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl InputSnap {

#[inline]
pub(super) fn reset(&mut self, limit: usize) {
self.cursor = self.cursor.min(self.value.chars().count().saturating_sub(self.mode.delta()));
self.cursor = self.cursor.min(self.count().saturating_sub(self.mode.delta()));
self.offset =
self.offset.min(self.cursor.saturating_sub(Self::find_window(&self.rev(), 0, limit).end));
}
Expand Down

0 comments on commit 6308873

Please sign in to comment.