From be3d0f8b33112430433ee15747c746a5fe135425 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 9 Jul 2019 19:29:19 +1000 Subject: [PATCH] Filter non-extra_word_chars completion candidates using Codepoints Fixes #3010 --- src/insert_completer.cc | 7 +++++-- .../3010-extra_word_chars-fails-with-other-buffers/cmd | 1 + .../3010-extra_word_chars-fails-with-other-buffers/in | 1 + .../3010-extra_word_chars-fails-with-other-buffers/out | 1 + .../3010-extra_word_chars-fails-with-other-buffers/rc | 1 + 5 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 test/regression/3010-extra_word_chars-fails-with-other-buffers/cmd create mode 100644 test/regression/3010-extra_word_chars-fails-with-other-buffers/in create mode 100644 test/regression/3010-extra_word_chars-fails-with-other-buffers/out create mode 100644 test/regression/3010-extra_word_chars-fails-with-other-buffers/rc diff --git a/src/insert_completer.cc b/src/insert_completer.cc index b49fa9bc..92adf361 100644 --- a/src/insert_completer.cc +++ b/src/insert_completer.cc @@ -136,8 +136,11 @@ InsertCompletion complete_word(const SelectionList& sels, continue; 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); })) + filter([&](auto& rm) { + auto&& c = rm.candidate(); + return std::all_of(utf8::iterator{c.begin(), c}, + utf8::iterator{c.end(), c}, + is_word_pred); })) matches.push_back({ m, buf.get() }); } } diff --git a/test/regression/3010-extra_word_chars-fails-with-other-buffers/cmd b/test/regression/3010-extra_word_chars-fails-with-other-buffers/cmd new file mode 100644 index 00000000..c50e70f0 --- /dev/null +++ b/test/regression/3010-extra_word_chars-fails-with-other-buffers/cmd @@ -0,0 +1 @@ +:e otheriword░AW diff --git a/test/regression/3010-extra_word_chars-fails-with-other-buffers/in b/test/regression/3010-extra_word_chars-fails-with-other-buffers/in new file mode 100644 index 00000000..1c2a6d45 --- /dev/null +++ b/test/regression/3010-extra_word_chars-fails-with-other-buffers/in @@ -0,0 +1 @@ +wo diff --git a/test/regression/3010-extra_word_chars-fails-with-other-buffers/out b/test/regression/3010-extra_word_chars-fails-with-other-buffers/out new file mode 100644 index 00000000..3959b4e9 --- /dev/null +++ b/test/regression/3010-extra_word_chars-fails-with-other-buffers/out @@ -0,0 +1 @@ +word░ diff --git a/test/regression/3010-extra_word_chars-fails-with-other-buffers/rc b/test/regression/3010-extra_word_chars-fails-with-other-buffers/rc new file mode 100644 index 00000000..26d072af --- /dev/null +++ b/test/regression/3010-extra_word_chars-fails-with-other-buffers/rc @@ -0,0 +1 @@ +set global extra_word_chars ░