summaryrefslogtreecommitdiff
path: root/Userland/Utilities
diff options
context:
space:
mode:
authordavidot <davidot@serenityos.org>2021-10-03 13:20:15 +0200
committerAndreas Kling <kling@serenityos.org>2021-10-03 17:42:05 +0200
commitf4f139773557d6254966617c45c5c34291d3aed9 (patch)
treeabaf825c029e594142ad6b0dbe7ad940010fa6d0 /Userland/Utilities
parent0be0e7ea6efada35ba6eab72041009501e192892 (diff)
downloadserenity-f4f139773557d6254966617c45c5c34291d3aed9.zip
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.
Diffstat (limited to 'Userland/Utilities')
-rw-r--r--Userland/Utilities/js.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp
index 6148243228..9f4b900e85 100644
--- a/Userland/Utilities/js.cpp
+++ b/Userland/Utilities/js.cpp
@@ -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;