Skip to content

Commit

Permalink
Merge f45f478 into 779e013
Browse files Browse the repository at this point in the history
  • Loading branch information
asterite authored Sep 4, 2024
2 parents 779e013 + f45f478 commit 01d4536
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 13 additions & 3 deletions compiler/noirc_frontend/src/hir/comptime/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1653,10 +1653,20 @@ impl<'local, 'interner> Interpreter<'local, 'interner> {
assert_eq!(arguments.len(), 2);

let print_newline = arguments[0].0 == Value::Bool(true);
if print_newline {
println!("{}", arguments[1].0.display(self.elaborator.interner));
let contents = arguments[1].0.display(self.elaborator.interner);
if self.elaborator.interner.is_in_lsp_mode() {
// If we `println!` in LSP it gets mixed with the protocol stream and leads to crashing
// the connection. If we use `eprintln!` not only it doesn't crash, but the output
// appears in the "Noir Language Server" output window in case you want to see it.
if print_newline {
eprintln!("{}", contents);
} else {
eprint!("{}", contents);
}
} else if print_newline {
println!("{}", contents);
} else {
print!("{}", arguments[1].0.display(self.elaborator.interner));
print!("{}", contents);
}

Ok(Value::Unit)
Expand Down
2 changes: 0 additions & 2 deletions tooling/nargo_cli/src/cli/lsp_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ pub(crate) fn run(_args: LspCommand, _config: NargoConfig) -> Result<(), CliErro
.service(router)
});

eprintln!("LSP starting...");

// Prefer truly asynchronous piped stdin/stdout without blocking tasks.
#[cfg(unix)]
let (stdin, stdout) = (
Expand Down

0 comments on commit 01d4536

Please sign in to comment.