From 804fb44756aa0140ba49ccf2ddf3c7bc2a48a7d4 Mon Sep 17 00:00:00 2001 From: Oleksiy Syvokon Date: Wed, 8 Apr 2026 12:22:40 +0300 Subject: [PATCH] Propagate PgDn/PgUp if it wasn't handled by editor This way these keys can be used for scrolling agent thread when the message is empty or when the cursor is already at the top/bottom of the text --- assets/keymaps/default-linux.json | 2 ++ assets/keymaps/default-windows.json | 2 ++ crates/editor/src/editor.rs | 31 +++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.json index 5ecca68e0404b400af2c285dc51df0a65d6fe07a..a7312fded193d285fc26f3a4b4c4473eb71fe32c 100644 --- a/assets/keymaps/default-linux.json +++ b/assets/keymaps/default-linux.json @@ -292,6 +292,8 @@ "down": "agent::ScrollOutputLineDown", "shift-pageup": "agent::ScrollOutputToPreviousMessage", "shift-pagedown": "agent::ScrollOutputToNextMessage", + "ctrl-home": "agent::ScrollOutputToTop", + "ctrl-end": "agent::ScrollOutputToBottom", "ctrl-alt-pageup": "agent::ScrollOutputPageUp", "ctrl-alt-pagedown": "agent::ScrollOutputPageDown", "ctrl-alt-home": "agent::ScrollOutputToTop", diff --git a/assets/keymaps/default-windows.json b/assets/keymaps/default-windows.json index a9eb3933423ff60fe60ac391b12773ce7146fb0d..5064c799b32a6a14103911afcc83ba3e8f3d66b3 100644 --- a/assets/keymaps/default-windows.json +++ b/assets/keymaps/default-windows.json @@ -293,6 +293,8 @@ "down": "agent::ScrollOutputLineDown", "shift-pageup": "agent::ScrollOutputToPreviousMessage", "shift-pagedown": "agent::ScrollOutputToNextMessage", + "ctrl-home": "agent::ScrollOutputToTop", + "ctrl-end": "agent::ScrollOutputToBottom", "ctrl-alt-pageup": "agent::ScrollOutputPageUp", "ctrl-alt-pagedown": "agent::ScrollOutputPageDown", "ctrl-alt-home": "agent::ScrollOutputToTop", diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index e6f597de7ff9138b226cd2474353ef8c2ce16ebb..ac64c4a24767a1813026277984a799d7e345ba03 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -14627,6 +14627,8 @@ impl Editor { }; let text_layout_details = &self.text_layout_details(window, cx); + let selection_count = self.selections.count(); + let first_selection = self.selections.first_anchor(); self.change_selections(effects, window, cx, |s| { s.move_with(&mut |map, selection| { @@ -14644,6 +14646,11 @@ impl Editor { selection.collapse_to(cursor, goal); }); }); + + if selection_count == 1 && first_selection.range() == self.selections.first_anchor().range() + { + cx.propagate(); + } } pub fn select_up(&mut self, _: &SelectUp, window: &mut Window, cx: &mut Context) { @@ -14751,6 +14758,9 @@ impl Editor { }; let text_layout_details = &self.text_layout_details(window, cx); + let selection_count = self.selections.count(); + let first_selection = self.selections.first_anchor(); + self.change_selections(effects, window, cx, |s| { s.move_with(&mut |map, selection| { if !selection.is_empty() { @@ -14767,6 +14777,11 @@ impl Editor { selection.collapse_to(cursor, goal); }); }); + + if selection_count == 1 && first_selection.range() == self.selections.first_anchor().range() + { + cx.propagate(); + } } pub fn select_down(&mut self, _: &SelectDown, window: &mut Window, cx: &mut Context) { @@ -15534,10 +15549,18 @@ impl Editor { cx.propagate(); return; } + let selection_count = self.selections.count(); + let first_selection = self.selections.first_anchor(); + self.hide_mouse_cursor(HideMouseCursorOrigin::MovementAction, cx); self.change_selections(Default::default(), window, cx, |s| { s.select_ranges(vec![Anchor::Min..Anchor::Min]); }); + + if selection_count == 1 && first_selection.range() == self.selections.first_anchor().range() + { + cx.propagate(); + } } pub fn select_to_beginning( @@ -15559,11 +15582,19 @@ impl Editor { cx.propagate(); return; } + let selection_count = self.selections.count(); + let first_selection = self.selections.first_anchor(); + self.hide_mouse_cursor(HideMouseCursorOrigin::MovementAction, cx); let cursor = self.buffer.read(cx).read(cx).len(); self.change_selections(Default::default(), window, cx, |s| { s.select_ranges(vec![cursor..cursor]) }); + + if selection_count == 1 && first_selection.range() == self.selections.first_anchor().range() + { + cx.propagate(); + } } pub fn set_nav_history(&mut self, nav_history: Option) {