**/
/* }}} */
+#include <typeinfo>
+
#include "cycript.hpp"
#include "Driver.hpp"
" if (name.substring(0, entire) == prefix)\n"
" names.push(name);\n"
" } else do {\n"
- " if (object.hasOwnProperty(\"cy$complete\")) {\n"
+ " if (object.hasOwnProperty(\"cy$complete\"))\n"
" names = names.concat(object.cy$complete(prefix, message));\n"
- " continue;\n"
- " }\n"
" try {\n"
" var local = Object.getOwnPropertyNames(object);\n"
" } catch (e) {\n"
_assert(value != NULL);
element = value->next_;
- CYString *string(dynamic_cast<CYString *>(value->value_));
- _assert(string != NULL);
-
- CYUTF8String completion;
- if (string->size_ != 0)
- completion = {string->value_, string->size_};
- else if (driver.mode_ == CYDriver::AutoMessage)
- completion = "]";
- else
- continue;
+ _assert(value->value_ != NULL);
+ CYString *string(value->value_->String(context));
+ if (string == NULL)
+ CYThrow("string was actually %s", typeid(*value->value_).name());
+ 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);