Fix --separate flag

This commit is contained in:
LoukasPap
2026-05-03 13:28:03 +02:00
committed by Sylvestre Ledru
parent c5cbd62f9b
commit 433635b583
3 changed files with 32 additions and 1 deletions
+5 -1
View File
@@ -695,9 +695,13 @@ pub fn process_all_files(
.map_err_context(|| format!("error opening input file {}", path.quote()))?;
let output = in_place.begin(path)?;
if index == 0 || context.separate {
if context.separate || index == 0 {
context.line_number = 0;
reset_latched_address_ranges(&mut context.range_commands);
// Reset hold space for separate file processing
context.hold.content.clear();
context.hold.has_newline = true;
}
context.input_name = path.quote().to_string();
+4
View File
@@ -380,6 +380,10 @@ check_output!(
pattern_hold_append_swap,
["-e", r"2h;3H;4g;5G;6x;6p;6x;6p", LINES1]
);
check_output!(
pattern_swap_separate,
["--separate", r"4x;6x", LINES1, LINES2]
);
check_output!(pattern_next_output, ["-e", r"4n", LINES1]);
check_output!(pattern_next_no_output, ["-n", "-e", r"4n", LINES1]);
check_output!(pattern_next_print_output, ["-e", r"4n;p", LINES1]);
+23
View File
@@ -0,0 +1,23 @@
l1_1
l1_2
l1_3
l1_5
l1_4
l1_7
l1_8
l1_9
l1_10
l1_11
l1_12
l1_13
l1_14
l2_1
l2_2
l2_3
l2_5
l2_4
l2_7
l2_8
l2_9