Skip to content

Commit 89848ad

Browse files
authored
fix: renaming may cause a crash when encountering Unicode characters (#519)
1 parent cb80ca8 commit 89848ad

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

yazi-core/src/manager/commands/rename.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,12 @@ impl Manager {
6464
let name = Self::empty_url_part(&hovered, opt.empty);
6565
let cursor = match opt.cursor {
6666
"start" => Some(0),
67-
"before_ext" => name.rfind('.').filter(|&n| n != 0),
67+
"before_ext" => name
68+
.chars()
69+
.rev()
70+
.position(|c| c == '.')
71+
.map(|i| name.chars().count() - i - 1)
72+
.filter(|&i| i != 0),
6873
_ => None,
6974
};
7075

0 commit comments

Comments
 (0)