summaryrefslogtreecommitdiff
path: root/Userland/Utilities
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2022-02-28 17:28:47 +0330
committerAndreas Kling <kling@serenityos.org>2022-03-06 13:20:41 +0100
commit118590325a0fe289e3e23b975b60c60d0a10c04e (patch)
treef78d86908f74b3202b47d5c4d5f0fb102024c756 /Userland/Utilities
parent1fcef99ff7bd05792e69b64c276c86c277e61f59 (diff)
downloadserenity-118590325a0fe289e3e23b975b60c60d0a10c04e.zip
LibLine+Userland: Make suggestion offsets per-suggestion
This allows the user to modify different parts of the input with different suggestions.
Diffstat (limited to 'Userland/Utilities')
-rw-r--r--Userland/Utilities/js.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp
index fe570e4a50..6672cd01fa 100644
--- a/Userland/Utilities/js.cpp
+++ b/Userland/Utilities/js.cpp
@@ -1580,6 +1580,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
Line::CompletionSuggestion completion { key, Line::CompletionSuggestion::ForSearch };
if (!results.contains_slow(completion)) { // hide duplicates
results.append(String(key));
+ results.last().invariant_offset = property_pattern.length();
}
}
}
@@ -1605,8 +1606,6 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto const* object = MUST(variable.to_object(interpreter->global_object()));
auto const& shape = object->shape();
list_all_properties(shape, property_name);
- if (results.size())
- editor.suggest(property_name.length());
break;
}
case CompleteVariable: {
@@ -1614,12 +1613,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
list_all_properties(variable.shape(), variable_name);
for (String& name : global_environment.declarative_record().bindings()) {
- if (name.starts_with(variable_name))
+ if (name.starts_with(variable_name)) {
results.empend(name);
+ results.last().invariant_offset = variable_name.length();
+ }
}
- if (results.size())
- editor.suggest(variable_name.length());
break;
}
default: