Use WHOLE_WORD search option in vim mode's whole-word search (#18725)
Instead of wrapping the search term with `\<...\>`, enable the `WHOLE_WORD` search option. The advantage of the search option is that it can be toggled with one click/key press (alt+w by default), and it doesn't require regex mode. Release Notes: - Vim mode's whole word search now uses the search bar's "Match whole words" option, instead of wrapping the search term with `\<...\>`. This allows easier toggling of whole-word search, and it also works without enabling the regex mode.
This commit is contained in:
parent
f05b440572
commit
71f4ca67c2
1 changed files with 4 additions and 4 deletions
|
@ -269,6 +269,9 @@ impl Vim {
|
||||||
if regex {
|
if regex {
|
||||||
options |= SearchOptions::REGEX;
|
options |= SearchOptions::REGEX;
|
||||||
}
|
}
|
||||||
|
if whole_word {
|
||||||
|
options |= SearchOptions::WHOLE_WORD;
|
||||||
|
}
|
||||||
if !search_bar.show(cx) {
|
if !search_bar.show(cx) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
@ -276,10 +279,7 @@ impl Vim {
|
||||||
drop(search_bar.search("", None, cx));
|
drop(search_bar.search("", None, cx));
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
let mut query = regex::escape(&query);
|
let query = regex::escape(&query);
|
||||||
if whole_word {
|
|
||||||
query = format!(r"\<{}\>", query);
|
|
||||||
}
|
|
||||||
Some(search_bar.search(&query, Some(options), cx))
|
Some(search_bar.search(&query, Some(options), cx))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue