diff options
author | Edwin Cheng <[email protected]> | 2020-01-08 21:06:15 +0000 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2020-01-12 12:25:58 +0000 |
commit | b7ab0792114fe66c61c921b08f6262123fb8ddd0 (patch) | |
tree | 8ac80354d3e0b49bdd2e45a13bf76b36c4c21fea | |
parent | caed836e417a239ae1e384f7e977352b846a3804 (diff) |
Use indices first and last instead of min-max
-rw-r--r-- | crates/ra_ide/src/extend_selection.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/crates/ra_ide/src/extend_selection.rs b/crates/ra_ide/src/extend_selection.rs index dc1a625ed..8048c7be9 100644 --- a/crates/ra_ide/src/extend_selection.rs +++ b/crates/ra_ide/src/extend_selection.rs | |||
@@ -139,9 +139,10 @@ fn extend_tokens_from_range( | |||
139 | }) | 139 | }) |
140 | .collect(); | 140 | .collect(); |
141 | 141 | ||
142 | // Compute the first and last token index in original_range | 142 | // The first and last token index in original_range |
143 | let first_idx = *indices.iter().min_by_key(|&&idx| all_tokens[idx].text_range().start())?; | 143 | // Note that the indices is sorted |
144 | let last_idx = *indices.iter().max_by_key(|&&idx| all_tokens[idx].text_range().end())?; | 144 | let first_idx = *indices.first()?; |
145 | let last_idx = *indices.last()?; | ||
145 | 146 | ||
146 | // compute original mapped token range | 147 | // compute original mapped token range |
147 | let expanded = { | 148 | let expanded = { |