X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/e257405a21801819aa1f5262b0c373c03fabbd58..451b00453196241914643fc1525f2d40afc14eec:/Complete.cpp diff --git a/Complete.cpp b/Complete.cpp index 1d715d7..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" @@ -175,21 +174,18 @@ _visible char **CYComplete(const char *word, const std::string &line, CYUTF8Stri element = value->next_; _assert(value->value_ != NULL); - CYString *string(dynamic_cast(value->value_)); + CYString *string(value->value_->String(context)); 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);