From 1c6b5581f01371a00dc7f6f6e1720ad8af61ec7a Mon Sep 17 00:00:00 2001 From: Nathan Vegdahl Date: Tue, 20 Jul 2021 11:58:56 -0700 Subject: Fix various bugs related to goto-end-of-line command. This also fixes a bug with `Selection::normalize()`, that could result in an out-of-bounds primary index. --- helix-core/src/selection.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'helix-core') diff --git a/helix-core/src/selection.rs b/helix-core/src/selection.rs index f1625f99..c08f504d 100644 --- a/helix-core/src/selection.rs +++ b/helix-core/src/selection.rs @@ -357,14 +357,14 @@ impl Selection { let mut prev_i = 0; for i in 1..self.ranges.len() { if self.ranges[prev_i].overlaps(&self.ranges[i]) { - if i == self.primary_index { - self.primary_index = prev_i; - } self.ranges[prev_i] = self.ranges[prev_i].merge(self.ranges[i]); } else { prev_i += 1; self.ranges[prev_i] = self.ranges[i]; } + if i == self.primary_index { + self.primary_index = prev_i; + } } self.ranges.truncate(prev_i + 1); -- cgit v1.2.3-70-g09d2