From 0eed7422f6a576146e9cd01cb460ec8b89aeecb3 Mon Sep 17 00:00:00 2001 From: Thomas Jensen Date: Sun, 3 Dec 2023 16:43:34 +0100 Subject: [PATCH] Restore indentation mode on box removal --- src/remove.c | 16 ++++++++++++---- test/190_remove_blank_nw_lines.txt | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/remove.c b/src/remove.c index c0b9258..bc736f8 100644 --- a/src/remove.c +++ b/src/remove.c @@ -1009,10 +1009,18 @@ static void remove_vertical_from_input(remove_ctx_t *ctx) #endif bxstr_t *temp2 = bxs_substr(org_line, s_idx, e_idx); - bxstr_t *temp = bxs_prepend_spaces(temp2, input.indent); - free_line_text(input.lines + input_line_idx); - input.lines[input_line_idx].text = temp; - bxs_free(temp2); + if (opt.indentmode == 'b' || opt.indentmode == '\0') { + /* restore indentation */ + bxstr_t *temp = bxs_prepend_spaces(temp2, input.indent); + free_line_text(input.lines + input_line_idx); + input.lines[input_line_idx].text = temp; + bxs_free(temp2); + } + else { + /* remove indentation */ + free_line_text(input.lines + input_line_idx); + input.lines[input_line_idx].text = temp2; + } } } diff --git a/test/190_remove_blank_nw_lines.txt b/test/190_remove_blank_nw_lines.txt index 0ffb98a..ed2e3db 100644 --- a/test/190_remove_blank_nw_lines.txt +++ b/test/190_remove_blank_nw_lines.txt @@ -23,5 +23,5 @@ Note that the NW corner is mostly blank (except its very bottom), which triggers (__/ \__) :OUTPUT-FILTER :EXPECTED - foobar + foobar :EOF