mirror of
https://github.com/denoland/deno.git
synced 2024-12-24 08:09:08 -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 fork = Fork::from_ptmx().unwrap();
|
||||
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();
|
||||
|
||||
let mut output = String::new();
|
||||
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();
|
||||
} else {
|
||||
|
|
|
@ -115,8 +115,19 @@ impl Completer for Helper {
|
|||
.as_array()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.map(|r| r.get("name").unwrap().as_str().unwrap().to_string())
|
||||
.filter(|r| r.starts_with(&suffix[1..]))
|
||||
.filter_map(|r| {
|
||||
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();
|
||||
|
||||
return Ok((pos - (suffix.len() - 1), candidates));
|
||||
|
|
Loading…
Reference in a new issue