summaryrefslogtreecommitdiff
path: root/cli/tools/repl/editor.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-03-15 21:41:13 -0400
committerGitHub <noreply@github.com>2023-03-15 21:41:13 -0400
commitc1eba16b84c5bba4f7fdf05beb6ccf5e0fd1da16 (patch)
tree8ce89ad74652f0f47daead27adc5b61ff4fa455a /cli/tools/repl/editor.rs
parent48a0b7f98f568bb5c3a15b487459569e38e4c671 (diff)
fix(repl): do not panic deleting `Deno` or deleting all its properties (#18211)
Closes #18194 Closes #12092
Diffstat (limited to 'cli/tools/repl/editor.rs')
-rw-r--r--cli/tools/repl/editor.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/cli/tools/repl/editor.rs b/cli/tools/repl/editor.rs
index bf38573f4..98e528614 100644
--- a/cli/tools/repl/editor.rs
+++ b/cli/tools/repl/editor.rs
@@ -39,6 +39,7 @@ use std::sync::Arc;
use super::cdp;
use super::channel::RustylineSyncMessageSender;
+use super::session::REPL_INTERNALS_NAME;
// Provides helpers to the editor like validation for multi-line edits, completion candidates for
// tab completion.
@@ -159,7 +160,7 @@ impl EditorHelper {
}
fn is_word_boundary(c: char) -> bool {
- if c == '.' {
+ if matches!(c, '.' | '_' | '$') {
false
} else {
char::is_ascii_whitespace(&c) || char::is_ascii_punctuation(&c)
@@ -207,7 +208,11 @@ impl Completer for EditorHelper {
let candidates = self
.get_expression_property_names(sub_expr)
.into_iter()
- .filter(|n| !n.starts_with("Symbol(") && n.starts_with(prop_name))
+ .filter(|n| {
+ !n.starts_with("Symbol(")
+ && n.starts_with(prop_name)
+ && n != &*REPL_INTERNALS_NAME
+ })
.collect();
Ok((pos - prop_name.len(), candidates))
@@ -217,7 +222,7 @@ impl Completer for EditorHelper {
.get_expression_property_names("globalThis")
.into_iter()
.chain(self.get_global_lexical_scope_names())
- .filter(|n| n.starts_with(expr))
+ .filter(|n| n.starts_with(expr) && n != &*REPL_INTERNALS_NAME)
.collect::<Vec<_>>();
// sort and remove duplicates