1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:47:36 +00:00

js: Allow for completion of lexically declared variables

This does require us to have a method which lists all the bindings in
a declarative environment which is not in the spec.
This commit is contained in:
davidot 2021-10-03 13:20:15 +02:00 committed by Andreas Kling
parent 0be0e7ea6e
commit f4f1397735
3 changed files with 18 additions and 0 deletions

View file

@ -1361,6 +1361,12 @@ int main(int argc, char** argv)
case CompleteVariable: {
auto const& variable = interpreter->global_object();
list_all_properties(variable.shape(), variable_name);
for (String& name : global_environment.declarative_record().bindings()) {
if (name.starts_with(variable_name))
results.empend(name);
}
if (results.size())
editor.suggest(variable_name.length());
break;