From 90dcf1b7a8c92b6da77872c56d9d269bb24fd487 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 7 Oct 2023 13:56:50 -0700 Subject: [PATCH] Revert "termio: clear screen always sends form feed (0x0C)" This reverts commit abc383854604189378bfe61239c14f263f7a14de. See #623 --- src/termio/Exec.zig | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/termio/Exec.zig b/src/termio/Exec.zig index cf6b1ab7c..3779fc4c0 100644 --- a/src/termio/Exec.zig +++ b/src/termio/Exec.zig @@ -379,12 +379,20 @@ pub fn clearScreen(self: *Exec, history: bool) !void { // Clear our scrollback if (history) try self.terminal.screen.clear(.history); - // Clear our screen using terminal state. - try self.terminal.screen.clear(.above_cursor); + // If we're not at a prompt, we clear the screen manually using + // the terminal screen state. If we are at a prompt, we send + // form-feed so that the shell can repaint the entire screen. + if (!self.terminal.cursorIsAtPrompt()) { + // Clear above the cursor + try self.terminal.screen.clear(.above_cursor); + + // Exit + return; + } } - // We also always send form feed so that the terminal can repaint - // our prompt. + // If we reached here it means we're at a prompt, so we send a form-feed. + assert(self.terminal.cursorIsAtPrompt()); try self.queueWrite(&[_]u8{0x0C}); }