Skip to content

Commit b7ab079

Browse files
committed
Use indices first and last instead of min-max
1 parent caed836 commit b7ab079

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

crates/ra_ide/src/extend_selection.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,10 @@ fn extend_tokens_from_range(
139139
})
140140
.collect();
141141

142-
// Compute 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())?;
144-
let last_idx = *indices.iter().max_by_key(|&&idx| all_tokens[idx].text_range().end())?;
142+
// The first and last token index in original_range
143+
// Note that the indices is sorted
144+
let first_idx = *indices.first()?;
145+
let last_idx = *indices.last()?;
145146

146147
// compute original mapped token range
147148
let expanded = {

0 commit comments

Comments
 (0)