From 383b7c5870bdebefeaa0aedbc0ae0f53170b09cb Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 7 Jan 2024 07:54:42 -0800 Subject: [PATCH] core: clear_screen binding doesn't consume on alt screen The clear_screen binding does nothing on the alternate screen already, but we were still marking the action as "performed" which caused the binding to be consumed. This meant that alt screen applications like neovim, tmux, etc. couldn't see "cmd+k" (default binding for clear_screen on macOS) without the Ghostty user unbinding it completely. We already have other bindings that do not consume only when they do not perform, such as `previous_tab` and `next_tab`. This extends the framework we built for that to this action. --- src/Surface.zig | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Surface.zig b/src/Surface.zig index dbc800654..c78959288 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -2788,6 +2788,17 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool }, .clear_screen => { + // This is a duplicate of some of the logic in termio.clearScreen + // but we need to do this here so we can know the answer before + // we send the message. If the currently active screen is on the + // alternate screen then clear screen does nothing so we want to + // return false so the keybind can be unconsumed. + { + self.renderer_state.mutex.lock(); + defer self.renderer_state.mutex.unlock(); + if (self.io.terminal.active_screen == .alternate) return false; + } + _ = self.io_thread.mailbox.push(.{ .clear_screen = .{ .history = true }, }, .{ .forever = {} });