[Toybox] [PATCH] vi: fix unchanged empty buffer marked as modified
Avery Terrel
averymt at proton.me
Mon Mar 2 12:17:33 PST 2026
Signed-off-by: Avery Terrel <avery at averymt.zip>
---
toys/pending/vi.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/toys/pending/vi.c b/toys/pending/vi.c
index ab457753..be8df42b 100644
--- a/toys/pending/vi.c
+++ b/toys/pending/vi.c
@@ -330,6 +330,7 @@ static int modified()
if (TT.slices->next != TT.slices->prev) return 1;
if (!TT.text || !TT.slices) return 0;
if (!TT.text->node || !TT.slices->node) return 0;
+ if (TT.text->node->len == 1 && TT.slices->node->len == 1 && *TT.text->node->data == '\n') return 0;
if (TT.text->node->alloc != MMAP) return 1;
if (TT.text->node->len != TT.slices->node->len) return 1;
if (!TT.text->node->len) return 1;
--
2.51.0
More information about the Toybox
mailing list