Commit 03ea9328 authored by Rasmus Rendal's avatar Rasmus Rendal

Fixed incorrect string slicing that would screw up UTF-8 strings

parent 1e3b6473
......@@ -363,7 +363,9 @@ fn get_selected_text(event_widget: Option<&gtk::Widget>) -> Option<SelectedText>
match w.get_selection_bounds() {
Some((s, e)) => {
let text = w.get_text()?;
let slice = text.get(s as usize..e as usize)?;
let slice: String = text.chars()
.take(e as usize).skip(s as usize)
Some(SelectedText{ widget: w.clone(), text: slice.to_string(), start: s, end: e })
_ => None
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment