on master help sign in
Fix extend_line() behavior.
848cc1bNathan Vegdahl
helix-term/src/commands.rs+6−7
@@ -900,14 +900,13 @@ fn extend_line(cx: &mut Context) {
900 let text = doc.text();
900 let text = doc.text();
901
901
902 let line_start = text.char_to_line(pos.anchor);
902 let line_start = text.char_to_line(pos.anchor);
903− let mut line = text.char_to_line(pos.head);
904− let line_end = line_end_char_index(&text.slice(..), line);
905− if line_start <= pos.anchor && pos.head == line_end && line < (text.len_lines() - 2) {
906− line += 1;
907− }
908−
909 let start = text.line_to_char(line_start);
903 let start = text.line_to_char(line_start);
904+ let line_end = text.char_to_line(pos.head);
910− let end = line_end_char_index(&text.slice(..), line);
905+ let mut end = line_end_char_index(&text.slice(..), line_end);
906+
907+ if pos.anchor == start && pos.head == end && line_end < (text.len_lines() - 2) {
908+ end = line_end_char_index(&text.slice(..), line_end + 1);
909+ }
911
910
912 doc.set_selection(view.id, Selection::single(start, end));
911 doc.set_selection(view.id, Selection::single(start, end));
913}
912}