InsertCompleter: only accept words matching the target buffer word definition
The words we store in the WordDB are dependent on the extra_word_chars options, which can be different for different buffers. When completing words in a buffer based on the WordDB from another buffer, some candidates might contains characters that are not considered word character for the target buffer, ignore those words.
This commit is contained in:
parent
a9f1a23f35
commit
70e2122ae6
|
@ -134,19 +134,14 @@ InsertCompletion complete_word(const SelectionList& sels, const OptionManager& o
|
||||||
};
|
};
|
||||||
Vector<RankedMatchAndBuffer> matches;
|
Vector<RankedMatchAndBuffer> matches;
|
||||||
|
|
||||||
auto add_matches = [&](const Buffer& buf) {
|
auto& word_db = get_word_db(buffer);
|
||||||
auto& word_db = get_word_db(buf);
|
for (auto& m : word_db.find_matching(prefix))
|
||||||
auto bufmatches = word_db.find_matching(prefix);
|
matches.push_back({ m, &buffer });
|
||||||
for (auto& m : bufmatches)
|
|
||||||
matches.push_back({ m, &buf });
|
|
||||||
};
|
|
||||||
|
|
||||||
add_matches(buffer);
|
|
||||||
|
|
||||||
// Remove words that are being edited
|
// Remove words that are being edited
|
||||||
for (auto& word_count : sel_word_counts)
|
for (auto& word_count : sel_word_counts)
|
||||||
{
|
{
|
||||||
if (get_word_db(buffer).get_word_occurences(word_count.key) <= word_count.value)
|
if (word_db.get_word_occurences(word_count.key) <= word_count.value)
|
||||||
unordered_erase(matches, word_count.key);
|
unordered_erase(matches, word_count.key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +151,11 @@ InsertCompletion complete_word(const SelectionList& sels, const OptionManager& o
|
||||||
{
|
{
|
||||||
if (buf.get() == &buffer or buf->flags() & Buffer::Flags::Debug)
|
if (buf.get() == &buffer or buf->flags() & Buffer::Flags::Debug)
|
||||||
continue;
|
continue;
|
||||||
add_matches(*buf);
|
for (auto& m : get_word_db(*buf).find_matching(prefix) |
|
||||||
|
// filter out words that are not considered words for the current buffer
|
||||||
|
filter([&](auto& rm) { return std::all_of(rm.candidate().begin(), rm.candidate().end(),
|
||||||
|
is_word_pred); }))
|
||||||
|
matches.push_back({ m, buf.get() });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user