mirror of
https://github.com/nushell/nushell.git
synced 2024-11-29 20:03:54 +01:00
Fix 'skip' support for binary streams (#5943)
This commit is contained in:
parent
c16d8f0d5f
commit
2da8310b11
@ -93,18 +93,17 @@ impl Command for Skip {
|
||||
let bytes = val.as_bytes();
|
||||
if bytes.len() < remaining {
|
||||
remaining -= bytes.len();
|
||||
output.extend_from_slice(bytes)
|
||||
//output.extend_from_slice(bytes)
|
||||
} else {
|
||||
output.extend_from_slice(&bytes[0..remaining]);
|
||||
output.extend_from_slice(&bytes[remaining..]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
Value::Binary { val: bytes, .. } => {
|
||||
if bytes.len() < remaining {
|
||||
remaining -= bytes.len();
|
||||
output.extend_from_slice(&bytes)
|
||||
} else {
|
||||
output.extend_from_slice(&bytes[0..remaining]);
|
||||
output.extend_from_slice(&bytes[remaining..]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1,2 +1,3 @@
|
||||
mod skip_;
|
||||
mod until;
|
||||
mod while_;
|
||||
|
16
crates/nu-command/tests/commands/skip/skip_.rs
Normal file
16
crates/nu-command/tests/commands/skip/skip_.rs
Normal file
@ -0,0 +1,16 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn binary_skip() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open sample_data.ods --raw |
|
||||
skip 2 |
|
||||
take 2 |
|
||||
into int
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "772");
|
||||
}
|
Loading…
Reference in New Issue
Block a user