on master help sign in
Fix extend_line() behavior.

It would always extend to the next line if the cursor was at the end of the current line, even if the current line wasn't fully selected yet.

commit848cc1b438ac75f90e72e35afe66a6e153ced4ac authorNathan Vegdahl <cessen@cessen.com> dateTue 22 Jun 2021, 19:07 (5 years ago) parent481c4ba
1 file changed+6−7
helix-term/src/commands.rs+6−7
helix-term/src/commands.rs+6−7
@@ -900,14 +900,13 @@ fn extend_line(cx: &mut Context) {
900900 let text = doc.text();
901901
902902 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−
909903 let start = text.line_to_char(line_start);
910− let end = line_end_char_index(&text.slice(..), line);
904+ let line_end = text.char_to_line(pos.head);
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+ }
911910
912911 doc.set_selection(view.id, Selection::single(start, end));
913912}