editor: Add a setting to show a scrollbar in completion menu (#41849)
A user on Discord requested this feature: https://discord.com/channels/869392257814519848/1434188637389717556/1434188637389717556 I added a scrollbar setting called `completion_menu_scrollbar` to the completion menu and defaulted it to "Never" to match past behavior. Release Notes: - editor: Add `editor.completion_menu_scrollbar` setting to show a scrollbar in the completion menu
This commit is contained in:
@@ -28,10 +28,12 @@ use std::{
|
||||
rc::Rc,
|
||||
};
|
||||
use task::ResolvedTask;
|
||||
use ui::{Color, IntoElement, ListItem, Pixels, Popover, Styled, prelude::*};
|
||||
use ui::{
|
||||
Color, IntoElement, ListItem, Pixels, Popover, ScrollAxes, Scrollbars, Styled, WithScrollbar,
|
||||
prelude::*,
|
||||
};
|
||||
use util::ResultExt;
|
||||
|
||||
use crate::CodeActionSource;
|
||||
use crate::hover_popover::{hover_markdown_style, open_markdown_url};
|
||||
use crate::{
|
||||
CodeActionProvider, CompletionId, CompletionItemKind, CompletionProvider, DisplayRow, Editor,
|
||||
@@ -39,7 +41,8 @@ use crate::{
|
||||
actions::{ConfirmCodeAction, ConfirmCompletion},
|
||||
split_words, styled_runs_for_code_label,
|
||||
};
|
||||
use settings::SnippetSortOrder;
|
||||
use crate::{CodeActionSource, EditorSettings};
|
||||
use settings::{Settings, SnippetSortOrder};
|
||||
|
||||
pub const MENU_GAP: Pixels = px(4.);
|
||||
pub const MENU_ASIDE_X_PADDING: Pixels = px(16.);
|
||||
@@ -261,6 +264,20 @@ impl Drop for CompletionsMenu {
|
||||
}
|
||||
}
|
||||
|
||||
struct CompletionMenuScrollBarSetting;
|
||||
|
||||
impl ui::scrollbars::GlobalSetting for CompletionMenuScrollBarSetting {
|
||||
fn get_value(_cx: &App) -> &Self {
|
||||
&Self
|
||||
}
|
||||
}
|
||||
|
||||
impl ui::scrollbars::ScrollbarVisibility for CompletionMenuScrollBarSetting {
|
||||
fn visibility(&self, cx: &App) -> ui::scrollbars::ShowScrollbar {
|
||||
EditorSettings::get_global(cx).completion_menu_scrollbar
|
||||
}
|
||||
}
|
||||
|
||||
impl CompletionsMenu {
|
||||
pub fn new(
|
||||
id: CompletionId,
|
||||
@@ -898,7 +915,17 @@ impl CompletionsMenu {
|
||||
}
|
||||
});
|
||||
|
||||
Popover::new().child(list).into_any_element()
|
||||
Popover::new()
|
||||
.child(
|
||||
div().child(list).custom_scrollbars(
|
||||
Scrollbars::for_settings::<CompletionMenuScrollBarSetting>()
|
||||
.show_along(ScrollAxes::Vertical)
|
||||
.tracked_scroll_handle(self.scroll_handle.clone()),
|
||||
window,
|
||||
cx,
|
||||
),
|
||||
)
|
||||
.into_any_element()
|
||||
}
|
||||
|
||||
fn render_aside(
|
||||
|
||||
Reference in New Issue
Block a user