]> git.saurik.com Git - cycript.git/blobdiff - Complete.cpp
Correct even more bugs in no line terminator code.
[cycript.git] / Complete.cpp
index c81f90eb15cde39166ce5967b61ead5298679c5e..6ce6671c7d0cdde879990da4faeebd4f70197cf8 100644 (file)
@@ -101,9 +101,20 @@ _visible char **CYComplete(const char *word, const std::string &line, CYUTF8Stri
     "       var before = prefix.length;\n"
     "       prefix += word;\n"
     "       var entire = prefix.length;\n"
-    "       for (var name in object)\n"
-    "           if (name.substring(0, entire) == prefix)\n"
-    "               names.push(name.substr(before));\n"
+    "       if (false) {\n"
+    "           for (var name in object)\n"
+    "               if (name.substring(0, entire) == prefix)\n"
+    "                   names.push(name.substr(before));\n"
+    "       } else do {\n"
+    "           try {\n"
+    "               var local = Object.getOwnPropertyNames(object);\n"
+    "           } catch (e) {\n"
+    "               continue;\n"
+    "           }\n"
+    "           for (var name of local)\n"
+    "               if (name.substring(0, entire) == prefix)\n"
+    "                   names.push(name.substr(before));\n"
+    "       } while (object = typeof object === 'object' ? Object.getPrototypeOf(object) : object.__proto__);\n"
     "       return names;\n"
     "   }\n"
     ), expression, $S(begin.c_str()), $S(word))));