From b7ab0792114fe66c61c921b08f6262123fb8ddd0 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Thu, 9 Jan 2020 05:06:15 +0800 Subject: Use indices first and last instead of min-max --- crates/ra_ide/src/extend_selection.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'crates/ra_ide/src') 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( }) .collect(); - // Compute the first and last token index in original_range - let first_idx = *indices.iter().min_by_key(|&&idx| all_tokens[idx].text_range().start())?; - let last_idx = *indices.iter().max_by_key(|&&idx| all_tokens[idx].text_range().end())?; + // The first and last token index in original_range + // Note that the indices is sorted + let first_idx = *indices.first()?; + let last_idx = *indices.last()?; // compute original mapped token range let expanded = { -- cgit v1.2.3