From 5883fc70af319d363f56cce99341ddda9e51e121 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 3 Jan 2016 19:11:49 -0800 Subject: [PATCH] Speed up tab completion and hide $cy* identifiers. --- Complete.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Complete.cpp b/Complete.cpp index 1b1d0dc..8240068 100644 --- a/Complete.cpp +++ b/Complete.cpp @@ -146,7 +146,7 @@ _visible char **CYComplete(const char *word, const std::string &line, CYUTF8Stri return NULL; // XXX: use an std::set? - typedef std::vector Completions; + typedef std::vector Completions; Completions completions; std::string common; @@ -160,27 +160,30 @@ _visible char **CYComplete(const char *word, const std::string &line, CYUTF8Stri CYString *string(dynamic_cast(value->value_)); _assert(string != NULL); - std::string completion; + CYUTF8String completion; if (string->size_ != 0) - completion.assign(string->value_, string->size_); + completion = {string->value_, string->size_}; else if (driver.mode_ == CYDriver::AutoMessage) completion = "]"; else continue; + if (CYStartsWith(completion, "$cy")) + continue; + completions.push_back(completion); if (!rest) { common = completion; rest = true; } else { - size_t limit(completion.size()), size(common.size()); + size_t limit(completion.size), size(common.size()); if (size > limit) common = common.substr(0, limit); else limit = size; for (limit = 0; limit != size; ++limit) - if (common[limit] != completion[limit]) + if (common[limit] != completion.data[limit]) break; if (limit != size) common = common.substr(0, limit); @@ -202,7 +205,7 @@ _visible char **CYComplete(const char *word, const std::string &line, CYUTF8Stri results[0] = strdup(common.c_str()); size_t index(0); for (Completions::const_iterator i(completions.begin()); i != completions.end(); ++i) - results[++index] = strdup(i->c_str()); + results[++index] = strdup(i->data); results[count + 1] = NULL; return results; -- 2.45.2