@@ -851,38 +851,27 @@ impl Terminal {
let url = link.unwrap().uri().to_owned();
let url_match = min_index..=max_index;
+ Some((url, true, url_match))
+ } else if let Some(url_match) = regex_match_at(term, point, &mut self.url_regex) {
+ let url = term.bounds_to_string(*url_match.start(), *url_match.end());
Some((url, true, url_match))
} else if let Some(word_match) = regex_match_at(term, point, &mut self.word_regex) {
- let maybe_url_or_path =
- term.bounds_to_string(*word_match.start(), *word_match.end());
- let original_match = word_match.clone();
+ let file_path = term.bounds_to_string(*word_match.start(), *word_match.end());
+
let (sanitized_match, sanitized_word) =
- if maybe_url_or_path.starts_with('[') && maybe_url_or_path.ends_with(']') {
+ if file_path.starts_with('[') && file_path.ends_with(']') {
(
Match::new(
word_match.start().add(term, Boundary::Cursor, 1),
word_match.end().sub(term, Boundary::Cursor, 1),
),
- maybe_url_or_path[1..maybe_url_or_path.len() - 1].to_owned(),
+ file_path[1..file_path.len() - 1].to_owned(),
)
} else {
- (word_match, maybe_url_or_path)
+ (word_match, file_path)
};
- let is_url = match regex_match_at(term, point, &mut self.url_regex) {
- Some(url_match) => {
- // `]` is a valid symbol in the `file://` URL, so the regex match will include it
- // consider that when ensuring that the URL match is the same as the original word
- if sanitized_match == original_match {
- url_match == sanitized_match
- } else {
- url_match.start() == sanitized_match.start()
- && url_match.end() == original_match.end()
- }
- }
- None => false,
- };
- Some((sanitized_word, is_url, sanitized_match))
+ Some((sanitized_word, false, sanitized_match))
} else {
None
};