X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/37dadc219da7f34c243c5c76c2eff2d3fa1f1051..b101f7547000aaa1354792aabc459de7cc9e91de:/Complete.cpp diff --git a/Complete.cpp b/Complete.cpp index fcf8f5d..47acf10 100644 --- a/Complete.cpp +++ b/Complete.cpp @@ -118,8 +118,7 @@ _visible char **CYComplete(const char *word, const std::string &line, CYUTF8Stri message = $ CYFalse(); driver.script_ = $ CYScript($ CYExpress($C4(ParseExpression(pool, - " function(value, prefix, word, message) {\n" - " var object = value;\n" + " function(object, prefix, word, message) {\n" " var names = [];\n" " var before = prefix.length;\n" " prefix += word;\n" @@ -130,7 +129,7 @@ _visible char **CYComplete(const char *word, const std::string &line, CYUTF8Stri " names.push(name);\n" " } else do {\n" " if (object.hasOwnProperty(\"cy$complete\"))\n" - " names = names.concat(object.cy$complete.call(value, prefix, message));\n" + " names = names.concat(object.cy$complete(prefix, message));\n" " try {\n" " var local = Object.getOwnPropertyNames(object);\n" " } catch (e) {\n" @@ -179,17 +178,14 @@ _visible char **CYComplete(const char *word, const std::string &line, CYUTF8Stri if (string == NULL) CYThrow("string was actually %s", typeid(*value->value_).name()); - CYUTF8String completion; - if (string->size_ != 0) - completion = {string->value_, string->size_}; - else if (driver.mode_ == CYDriver::AutoMessage) - completion = "]"; - else - continue; - + CYUTF8String completion(string->value_, string->size_); + _assert(completion.size >= begin.size()); completion.data += begin.size(); completion.size -= begin.size(); + if (completion.size == 0 && driver.mode_ == CYDriver::AutoMessage) + completion = "]"; + if (CYStartsWith(completion, "$cy")) continue; completions.push_back(completion);