Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

textinput.rs replace_selection now slices wrt bytes rather than chars #20208

Closed
wants to merge 6 commits into from
Next

textinput.rs replace_selection now slices wrt bytes rather than chara…

…cters
  • Loading branch information
sarkhanbayramli committed Mar 6, 2018
commit 0a5e9ccaa815b5fbbb6c2d79462465085212adb7
@@ -378,9 +378,12 @@ impl<T: ClipboardProvider> TextInput<T> {

self.clear_selection();

// Calculate byte start and end for handling multi-byte characters
let start_index_b = len_of_first_n_code_units(&self.lines[start.line], start.index);
let end_index_b = len_of_first_n_code_units(&self.lines[end.line], end.index);
let new_lines = {
let prefix = &self.lines[start.line][..start.index];
let suffix = &self.lines[end.line][end.index..];
let prefix = &self.lines[start.line][..start_index_b];
let suffix = &self.lines[end.line][end_index_b..];
let lines_prefix = &self.lines[..start.line];
let lines_suffix = &self.lines[end.line + 1..];

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.