diff --git a/src/bin/relish.rs b/src/bin/relish.rs index 226c8ab..d44df1a 100644 --- a/src/bin/relish.rs +++ b/src/bin/relish.rs @@ -240,21 +240,20 @@ fn incomplete_brackets(line: &str) -> bool { for c in line.chars() { match c { c if ['"', '`', '\''].contains(&c) => { - match within_string { - Some(w) if c == w => { - balance.pop(); - within_string = None - } - Some(_) => {}, - None => { - balance.push(c); - within_string = Some(c) - }, - } - }, - - '(' if within_string.is_none() => balance.push(')'), + match within_string { + Some(w) if c == w => { + balance.pop(); + within_string = None + } + Some(_) => {}, + None => { + balance.push(c); + within_string = Some(c) + }, + } + }, + '(' if within_string.is_none() => balance.push(')'), ')' => if let Some(last) = balance.last() { if last == &c { balance.pop(); @@ -391,7 +390,10 @@ fn main() { match user_doc { Signal::Success(line) => { println!(""); // add a new line before output gets printed - let l = line.as_str().to_owned(); + let mut l = line.as_str().to_owned(); + if !l.starts_with('(') { + l = "(".to_owned() + &l + ")"; + } match lex(&l) { Ok(a) => match eval(&a, &mut syms) { Ok(a) => println!("{}", a),