check signals in nu-glob and ls (#15140)

Fixes #10144

# User-Facing Changes

Long running glob expansions and `ls` runs (e.g. `ls /**/*`) can now be
interrupted with ctrl-c.
This commit is contained in:
Solomon
2025-02-28 11:36:39 -07:00
committed by GitHub
parent 48bdcc71f4
commit c5a14bb8ff
14 changed files with 120 additions and 58 deletions

View File

@ -1,6 +1,6 @@
use nu_glob::MatchOptions;
use nu_path::{canonicalize_with, expand_path_with};
use nu_protocol::{shell_error::io::IoError, NuGlob, ShellError, Span, Spanned};
use nu_protocol::{shell_error::io::IoError, NuGlob, ShellError, Signals, Span, Spanned};
use std::{
fs,
path::{Component, Path, PathBuf},
@ -19,6 +19,7 @@ pub fn glob_from(
cwd: &Path,
span: Span,
options: Option<MatchOptions>,
signals: Signals,
) -> Result<
(
Option<PathBuf>,
@ -90,7 +91,7 @@ pub fn glob_from(
let pattern = pattern.to_string_lossy().to_string();
let glob_options = options.unwrap_or_default();
let glob = nu_glob::glob_with(&pattern, glob_options).map_err(|e| {
let glob = nu_glob::glob_with(&pattern, glob_options, signals).map_err(|e| {
nu_protocol::ShellError::GenericError {
error: "Error extracting glob pattern".into(),
msg: e.to_string(),