More functional style for '*' code
This commit is contained in:
parent
c54e0ec873
commit
b18ca12882
|
@ -939,20 +939,14 @@ template<bool smart>
|
||||||
void use_selection_as_search_pattern(Context& context, NormalParams params)
|
void use_selection_as_search_pattern(Context& context, NormalParams params)
|
||||||
{
|
{
|
||||||
const auto& buffer = context.buffer();
|
const auto& buffer = context.buffer();
|
||||||
String pattern;
|
auto patterns = context.selections() | transform([&](auto&& sel) {
|
||||||
|
|
||||||
for (auto& sel : context.selections())
|
|
||||||
{
|
|
||||||
const auto beg = sel.min(), end = buffer.char_next(sel.max());
|
const auto beg = sel.min(), end = buffer.char_next(sel.max());
|
||||||
const String sel_pattern = format("{}{}{}",
|
return format("{}{}{}",
|
||||||
smart and is_bow(buffer, beg) ? "\\b" : "",
|
smart and is_bow(buffer, beg) ? "\\b" : "",
|
||||||
escape(buffer.string(beg, end), "^$\\.*+?()[]{}|", '\\'),
|
escape(buffer.string(beg, end), "^$\\.*+?()[]{}|", '\\'),
|
||||||
smart and is_eow(buffer, end) ? "\\b" : "");
|
smart and is_eow(buffer, end) ? "\\b" : "");
|
||||||
|
});
|
||||||
if (not pattern.empty())
|
String pattern = join(patterns, '|', false);
|
||||||
pattern += '|';
|
|
||||||
pattern += sel_pattern;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char reg = to_lower(params.reg ? params.reg : '/');
|
const char reg = to_lower(params.reg ? params.reg : '/');
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user