From 684a58fc84491d21d5a034ac442f14f8f0bdb6d4 Mon Sep 17 00:00:00 2001 From: ihavecoke Date: Wed, 26 Nov 2025 17:09:26 +0800 Subject: [PATCH] Implement vertical scrolling for extended keymap load error information (#42542) This PR fix an issue where, if an error occurs while loading the keymap file during application startup, an excessively long error message would be truncated and not fully displayed. Before: before After: image Release Notes: - N/A --- crates/workspace/src/notifications.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/crates/workspace/src/notifications.rs b/crates/workspace/src/notifications.rs index 6c1156b83396d1266bc46bca67f10f3f57adfec4..75c35cda22d72d659040154a079fe78af78cf414 100644 --- a/crates/workspace/src/notifications.rs +++ b/crates/workspace/src/notifications.rs @@ -593,9 +593,9 @@ pub mod simple_message_notification { use gpui::{ AnyElement, DismissEvent, EventEmitter, FocusHandle, Focusable, ParentElement, Render, - SharedString, Styled, + ScrollHandle, SharedString, Styled, }; - use ui::prelude::*; + use ui::{WithScrollbar, prelude::*}; use crate::notifications::NotificationFrame; @@ -617,6 +617,7 @@ pub mod simple_message_notification { show_close_button: bool, show_suppress_button: bool, title: Option, + scroll_handle: ScrollHandle, } impl Focusable for MessageNotification { @@ -661,6 +662,7 @@ pub mod simple_message_notification { show_suppress_button: true, title: None, focus_handle: cx.focus_handle(), + scroll_handle: ScrollHandle::new(), } } @@ -777,7 +779,18 @@ pub mod simple_message_notification { fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { NotificationFrame::new() .with_title(self.title.clone()) - .with_content((self.build_content)(window, cx)) + .with_content( + div() + .child( + div() + .id("message-notification-content") + .max_h(vh(0.6, window)) + .overflow_y_scroll() + .track_scroll(&self.scroll_handle.clone()) + .child((self.build_content)(window, cx)), + ) + .vertical_scrollbar_for(self.scroll_handle.clone(), window, cx), + ) .show_close_button(self.show_close_button) .show_suppress_button(self.show_suppress_button) .on_close(cx.listener(|_, suppress, _, cx| {