minor cleanups in complete_word
This commit is contained in:
parent
eab2cc240a
commit
8cc9a44d47
|
@ -463,14 +463,12 @@ static std::pair<CandidateList, BufferIterator> complete_word(const BufferIterat
|
||||||
++begin;
|
++begin;
|
||||||
|
|
||||||
const Buffer& buffer = pos.buffer();
|
const Buffer& buffer = pos.buffer();
|
||||||
String prefix = buffer.string(begin, end);
|
String ex = R"(\<\Q)" + buffer.string(begin, end) + R"(\E\w+\>)";
|
||||||
String ex = "\\<\\Q" + prefix + "\\E\\w+\\>";
|
|
||||||
Regex re(ex.begin(), ex.end());
|
Regex re(ex.begin(), ex.end());
|
||||||
boost::regex_iterator<BufferIterator> it(buffer.begin(), buffer.end(), re);
|
using RegexIt = boost::regex_iterator<BufferIterator>;
|
||||||
boost::regex_iterator<BufferIterator> re_end;
|
|
||||||
|
|
||||||
CandidateList result;
|
CandidateList result;
|
||||||
for (; it != re_end; ++it)
|
for (RegexIt it(buffer.begin(), buffer.end(), re), re_end; it != re_end; ++it)
|
||||||
{
|
{
|
||||||
auto& match = (*it)[0];
|
auto& match = (*it)[0];
|
||||||
if (match.first <= pos and pos < match.second)
|
if (match.first <= pos and pos < match.second)
|
||||||
|
@ -481,7 +479,7 @@ static std::pair<CandidateList, BufferIterator> complete_word(const BufferIterat
|
||||||
result.emplace_back(std::move(content));
|
result.emplace_back(std::move(content));
|
||||||
}
|
}
|
||||||
std::sort(result.begin(), result.end());
|
std::sort(result.begin(), result.end());
|
||||||
return { result, begin };
|
return { std::move(result), begin };
|
||||||
}
|
}
|
||||||
|
|
||||||
class BufferCompleter
|
class BufferCompleter
|
||||||
|
|
Loading…
Reference in New Issue
Block a user