diff --git a/docs/examples/default-copy-mode-key-table.markdown b/docs/examples/default-copy-mode-key-table.markdown index 8050f9d77c3..a04fbd85be2 100644 --- a/docs/examples/default-copy-mode-key-table.markdown +++ b/docs/examples/default-copy-mode-key-table.markdown @@ -16,7 +16,10 @@ return { mods = 'NONE', action = act.CopyMode 'MoveToStartOfNextLine', }, - { key = 'Escape', mods = 'NONE', action = act.CopyMode 'Close' }, + { key = 'Escape', mods = 'NONE', action = act.Multiple { + { CopyMode = 'ScrollToBottom' }, + { CopyMode = 'Close' }, + } }, { key = 'Space', mods = 'NONE', @@ -124,7 +127,10 @@ return { { key = 'b', mods = 'NONE', action = act.CopyMode 'MoveBackwardWord' }, { key = 'b', mods = 'ALT', action = act.CopyMode 'MoveBackwardWord' }, { key = 'b', mods = 'CTRL', action = act.CopyMode 'PageUp' }, - { key = 'c', mods = 'CTRL', action = act.CopyMode 'Close' }, + { key = 'c', mods = 'CTRL', action = act.Multiple { + { CopyMode = 'ScrollToBottom' }, + { CopyMode = 'Close' }, + } }, { key = 'd', mods = 'CTRL', @@ -147,7 +153,10 @@ return { mods = 'NONE', action = act.CopyMode 'MoveToScrollbackTop', }, - { key = 'g', mods = 'CTRL', action = act.CopyMode 'Close' }, + { key = 'g', mods = 'CTRL', action = act.Multiple { + { CopyMode = 'ScrollToBottom' }, + { CopyMode = 'Close' }, + } }, { key = 'h', mods = 'NONE', action = act.CopyMode 'MoveLeft' }, { key = 'j', mods = 'NONE', action = act.CopyMode 'MoveDown' }, { key = 'k', mods = 'NONE', action = act.CopyMode 'MoveUp' }, @@ -162,7 +171,10 @@ return { mods = 'NONE', action = act.CopyMode 'MoveToSelectionOtherEnd', }, - { key = 'q', mods = 'NONE', action = act.CopyMode 'Close' }, + { key = 'q', mods = 'NONE', action = act.Multiple { + { CopyMode = 'ScrollToBottom' }, + { CopyMode = 'Close' }, + } }, { key = 't', mods = 'NONE', @@ -189,6 +201,7 @@ return { mods = 'NONE', action = act.Multiple { { CopyTo = 'ClipboardAndPrimarySelection' }, + { CopyMode = 'ScrollToBottom' }, { CopyMode = 'Close' }, }, }, diff --git a/wezterm-gui/src/overlay/copy.rs b/wezterm-gui/src/overlay/copy.rs index 24304f472ef..fc1b92a1281 100644 --- a/wezterm-gui/src/overlay/copy.rs +++ b/wezterm-gui/src/overlay/copy.rs @@ -557,7 +557,6 @@ impl CopyRenderable { } fn close(&self) { - self.set_viewport(None); TermWindow::schedule_cancel_overlay_for_pane(self.window.clone(), self.delegate.pane_id()); } @@ -1574,28 +1573,35 @@ pub fn search_key_table() -> KeyTable { table } +fn scroll_to_bottom_and_close() -> KeyAssignment { + KeyAssignment::Multiple(vec![ + KeyAssignment::ScrollToBottom, + KeyAssignment::CopyMode(CopyModeAssignment::Close), + ]) +} + pub fn copy_key_table() -> KeyTable { let mut table = KeyTable::default(); for (key, mods, action) in [ ( WKeyCode::Char('c'), Modifiers::CTRL, - KeyAssignment::CopyMode(CopyModeAssignment::Close), + scroll_to_bottom_and_close(), ), ( WKeyCode::Char('g'), Modifiers::CTRL, - KeyAssignment::CopyMode(CopyModeAssignment::Close), + scroll_to_bottom_and_close(), ), ( WKeyCode::Char('q'), Modifiers::NONE, - KeyAssignment::CopyMode(CopyModeAssignment::Close), + scroll_to_bottom_and_close(), ), ( WKeyCode::Char('\x1b'), Modifiers::NONE, - KeyAssignment::CopyMode(CopyModeAssignment::Close), + scroll_to_bottom_and_close(), ), ( WKeyCode::Char('h'), @@ -1847,7 +1853,7 @@ pub fn copy_key_table() -> KeyTable { Modifiers::NONE, KeyAssignment::Multiple(vec![ KeyAssignment::CopyTo(ClipboardCopyDestination::ClipboardAndPrimarySelection), - KeyAssignment::CopyMode(CopyModeAssignment::Close), + scroll_to_bottom_and_close(), ]), ), (