diff options
| author | Maxime Coste <mawww@kakoune.org> | 2017-02-23 00:35:27 +0000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2017-02-23 00:35:27 +0000 |
| commit | 73bb260e6cc751c9fb04aebfee9da5bf4640c6e4 (patch) | |
| tree | f357451f1615b6dd0ca2eec2efb6f29f005ce311 /src/word_db.cc | |
| parent | 2f7313ad595e712d33869c209bf88fcd2b7bf8b9 (diff) | |
Fix support for non ascii chars in completion_extra_word_char
Diffstat (limited to 'src/word_db.cc')
| -rw-r--r-- | src/word_db.cc | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/word_db.cc b/src/word_db.cc index de2deefe..4a66f9f4 100644 --- a/src/word_db.cc +++ b/src/word_db.cc @@ -10,13 +10,13 @@ namespace Kakoune using WordList = Vector<StringView>; -static WordList get_words(StringView content, StringView extra_word_chars) +static WordList get_words(StringView content, ConstArrayView<Codepoint> extra_word_chars) { WordList res; using Utf8It = utf8::iterator<const char*>; const char* word_start = content.begin(); bool in_word = false; - for (Utf8It it{word_start, content}, end{content.end(), content}; it != end; ++it) + for (Utf8It it{word_start, content}; it != content.end(); ++it) { Codepoint c = *it; const bool word = is_word(c) or contains(extra_word_chars, c); @@ -36,9 +36,13 @@ static WordList get_words(StringView content, StringView extra_word_chars) return res; } -static StringView get_extra_word_chars(const Buffer& buffer) +static Vector<Codepoint> get_extra_word_chars(const Buffer& buffer) { - return buffer.options()["completion_extra_word_char"].get<String>(); + auto& str = buffer.options()["completion_extra_word_char"].get<String>(); + Vector<Codepoint> res; + for (utf8::iterator<const char*> it{str.begin(), str}; it != str.end(); ++it) + res.push_back(*it); + return res; } void WordDB::add_words(StringView line) @@ -77,9 +81,9 @@ WordDB::WordDB(const Buffer& buffer) WordDB::WordDB(WordDB&& other) : m_buffer{std::move(other.m_buffer)}, - m_lines{std::move(other.m_lines)}, + m_timestamp{other.m_timestamp}, m_words{std::move(other.m_words)}, - m_timestamp{other.m_timestamp} + m_lines{std::move(other.m_lines)} { kak_assert(m_buffer); m_buffer->options().unregister_watcher(other); |
