Skip to content

fix(ext/node): emit resize event on SIGWINCH #27363

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 40 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ rustls = { version = "0.23.11", default-features = false, features = ["logging",
rustls-pemfile = "2"
rustls-tokio-stream = "=0.3.0"
rustls-webpki = "0.102"
rustyline = "=13.0.0"
rustyline-derive = "=0.7.0"
rustyline = { version = "=15.0.0", features = ["buffer-redux", "signal-hook"] }
rustyline-derive = "=0.9.0"
saffron = "=0.1.0"
same-file = "1.0.6"
scopeguard = "1.2.0"
Expand Down Expand Up @@ -358,7 +358,7 @@ quote = "1"
syn = { version = "2", features = ["full", "extra-traits"] }

# unix
nix = "=0.27.1"
nix = "=0.29.0"

# windows deps
junction = "=1.2.0"
Expand Down
3 changes: 2 additions & 1 deletion cli/tools/repl/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use deno_core::parking_lot::Mutex;
use deno_core::serde_json;
use rustyline::completion::Completer;
use rustyline::error::ReadlineError;
use rustyline::highlight::CmdKind;
use rustyline::highlight::Highlighter;
use rustyline::validate::ValidationContext;
use rustyline::validate::ValidationResult;
Expand Down Expand Up @@ -342,7 +343,7 @@ impl Highlighter for EditorHelper {
}
}

fn highlight_char(&self, line: &str, _: usize, _: bool) -> bool {
fn highlight_char(&self, line: &str, _: usize, _: CmdKind) -> bool {
!line.is_empty()
}

Expand Down
10 changes: 10 additions & 0 deletions ext/node/polyfills/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,11 @@ internals.__bootstrapNodeProcess = function (
"stdout",
);
}
if (stdout.isTTY) {
Deno.addSignalListener("SIGWINCH", () => {
stdout.emit("resize");
});
}

if (!io.stderr.isTerminal()) {
/** https://nodejs.org/api/process.html#process_process_stderr */
Expand All @@ -965,6 +970,11 @@ internals.__bootstrapNodeProcess = function (
"stderr",
);
}
if (stderr.isTTY) {
Deno.addSignalListener("SIGWINCH", () => {
stderr.emit("resize");
});
}

arch = arch_();
platform = isWindows ? "win32" : Deno.build.os;
Expand Down
2 changes: 1 addition & 1 deletion runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ ntapi = "0.4.0"
windows-sys.workspace = true

[target.'cfg(unix)'.dependencies]
nix.workspace = true
nix = { workspace = true, features = ["term"] }

[dev-dependencies]
# Used in benchmark
Expand Down
2 changes: 1 addition & 1 deletion runtime/ops/tty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ pub fn op_read_line_prompt(
let mut editor = Editor::<(), rustyline::history::DefaultHistory>::new()
.expect("Failed to create editor.");

editor.set_keyseq_timeout(1);
editor.set_keyseq_timeout(Some(1));
editor
.bind_sequence(KeyEvent(KeyCode::Esc, Modifiers::empty()), Cmd::Interrupt);

Expand Down
Loading