summaryrefslogtreecommitdiff
path: root/helix-core/src/selection.rs
diff options
context:
space:
mode:
authorNathan Vegdahl2021-07-20 18:58:56 +0000
committerNathan Vegdahl2021-07-20 18:58:56 +0000
commit1c6b5581f01371a00dc7f6f6e1720ad8af61ec7a (patch)
treec1758df277987266251500fc5c864f1def5c715c /helix-core/src/selection.rs
parente8a3980e464a9c98c3f76cada6c46a66498dc2bf (diff)
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.
Diffstat (limited to 'helix-core/src/selection.rs')
-rw-r--r--helix-core/src/selection.rs6
1 files changed, 3 insertions, 3 deletions
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);