summaryrefslogtreecommitdiff
path: root/devtools/shared/webconsole/js-property-provider.js
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/shared/webconsole/js-property-provider.js')
-rw-r--r--devtools/shared/webconsole/js-property-provider.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/devtools/shared/webconsole/js-property-provider.js b/devtools/shared/webconsole/js-property-provider.js
index dff2af50a6..64b78673e0 100644
--- a/devtools/shared/webconsole/js-property-provider.js
+++ b/devtools/shared/webconsole/js-property-provider.js
@@ -178,6 +178,22 @@ function JSPropertyProvider(dbgObject, anEnvironment, inputValue, cursor) {
}
let completionPart = inputValue.substring(beginning.startPos);
+
+ // Strip optional chaining characters from completion part, which we check
+ // by looking if it has ?. and if there are no digits (marker for ternary).
+ let optionalChainRegex = /\?\./g;
+ let optionalElemAccessRegex = /\?\.\[/g;
+ let digitRegex = /\?\.\d/;
+ // Handle optional element access
+ if (optionalElemAccessRegex.test(completionPart)) {
+ completionPart = completionPart.replace(optionalElemAccessRegex, "[");
+ }
+ // Handle optional chaining characters
+ if (optionalChainRegex.test(completionPart) &&
+ !digitRegex.test(completionPart)) {
+ completionPart = completionPart.replace(optionalChainRegex, ".");
+ }
+
let lastDot = completionPart.lastIndexOf(".");
// Don't complete on just an empty string.