Skip to content

Commit 8db8dc1

Browse files
authored
fix: unicode segmentation for inital selection when renaming file (#1419)
1 parent ffa0c74 commit 8db8dc1

File tree

1 file changed

+8
-1
lines changed
  • crates/rnote-ui/src/workspacebrowser/filerow/actions

1 file changed

+8
-1
lines changed

crates/rnote-ui/src/workspacebrowser/filerow/actions/rename.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use gettextrs::gettext;
55
use gtk4::{Align, Entry, Label, gio, glib, glib::clone, pango, prelude::*};
66
use std::path::Path;
77
use tracing::{debug, error};
8+
use unicode_segmentation::UnicodeSegmentation;
89

910
/// Create a new `rename` action.
1011
pub(crate) fn rename(filerow: &RnFileRow, appwindow: &RnAppWindow) -> gio::SimpleAction {
@@ -112,7 +113,13 @@ fn create_entry(current_path: impl AsRef<Path>) -> Entry {
112113

113114
fn entry_text_select_stem(entry: &Entry) {
114115
let entry_text = entry.text();
115-
let stem_end = entry_text.match_indices('.').map(|(i, _)| i).next_back();
116+
117+
let stem_end = entry_text
118+
.graphemes(true)
119+
.enumerate()
120+
.filter(|(_, g)| *g == ".")
121+
.last()
122+
.map(|(i, _)| i);
116123

117124
// Select entire text first
118125
entry.grab_focus();

0 commit comments

Comments
 (0)