mirror of
https://github.com/denoland/deno.git
synced 2025-01-12 09:03:42 -05:00
fix(repl): filter out symbol candidates (#9555)
This commit is contained in:
parent
14ec22e880
commit
b47f9cee8c
2 changed files with 42 additions and 4 deletions
|
@ -1844,13 +1844,40 @@ mod integration {
|
||||||
let deno_exe = util::deno_exe_path();
|
let deno_exe = util::deno_exe_path();
|
||||||
let fork = Fork::from_ptmx().unwrap();
|
let fork = Fork::from_ptmx().unwrap();
|
||||||
if let Ok(mut master) = fork.is_parent() {
|
if let Ok(mut master) = fork.is_parent() {
|
||||||
master.write_all(b"Deno.internal\t\n").unwrap();
|
master.write_all(b"Symbol.it\t\n").unwrap();
|
||||||
master.write_all(b"close();\n").unwrap();
|
master.write_all(b"close();\n").unwrap();
|
||||||
|
|
||||||
let mut output = String::new();
|
let mut output = String::new();
|
||||||
master.read_to_string(&mut output).unwrap();
|
master.read_to_string(&mut output).unwrap();
|
||||||
|
|
||||||
assert!(output.contains("Symbol(Deno.internal)"));
|
assert!(output.contains("Symbol(Symbol.iterator)"));
|
||||||
|
|
||||||
|
fork.wait().unwrap();
|
||||||
|
} else {
|
||||||
|
std::env::set_var("NO_COLOR", "1");
|
||||||
|
let err = exec::Command::new(deno_exe).arg("repl").exec();
|
||||||
|
println!("err {}", err);
|
||||||
|
unreachable!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[test]
|
||||||
|
fn pty_ignore_symbols() {
|
||||||
|
use std::io::Read;
|
||||||
|
use util::pty::fork::*;
|
||||||
|
let deno_exe = util::deno_exe_path();
|
||||||
|
let fork = Fork::from_ptmx().unwrap();
|
||||||
|
if let Ok(mut master) = fork.is_parent() {
|
||||||
|
master.write_all(b"Array.Symbol\t\n").unwrap();
|
||||||
|
master.write_all(b"close();\n").unwrap();
|
||||||
|
|
||||||
|
let mut output = String::new();
|
||||||
|
master.read_to_string(&mut output).unwrap();
|
||||||
|
|
||||||
|
assert!(output.contains("undefined"));
|
||||||
|
assert!(!output
|
||||||
|
.contains("Uncaught TypeError: Array.Symbol is not a function"));
|
||||||
|
|
||||||
fork.wait().unwrap();
|
fork.wait().unwrap();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -115,8 +115,19 @@ impl Completer for Helper {
|
||||||
.as_array()
|
.as_array()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.iter()
|
.iter()
|
||||||
.map(|r| r.get("name").unwrap().as_str().unwrap().to_string())
|
.filter_map(|r| {
|
||||||
.filter(|r| r.starts_with(&suffix[1..]))
|
let name = r.get("name").unwrap().as_str().unwrap().to_string();
|
||||||
|
|
||||||
|
if name.starts_with("Symbol(") {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
if name.starts_with(&suffix[1..]) {
|
||||||
|
return Some(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
None
|
||||||
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
return Ok((pos - (suffix.len() - 1), candidates));
|
return Ok((pos - (suffix.len() - 1), candidates));
|
||||||
|
|
Loading…
Reference in a new issue