]> git.saurik.com Git - cycript.git/blobdiff - Complete.cpp
Guarantee all the older Cydget bridge definitions.
[cycript.git] / Complete.cpp
index fcf8f5dc364e6b4def21964068c067e5e2ca5f5b..47acf10263097d075274ef2625d76d40fc5de14c 100644 (file)
@@ -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);