Add setting to disable completion docs

This commit is contained in:
Julia 2023-10-12 22:08:47 -04:00
parent 1c3ecc4ad2
commit ec4391b88e
3 changed files with 27 additions and 2 deletions

View file

@ -50,6 +50,9 @@
// Whether to pop the completions menu while typing in an editor without
// explicitly requesting it.
"show_completions_on_input": true,
// Whether to display inline and alongside documentation for items in the
// completions menu
"show_completion_documentation": true,
// Whether to show wrap guides in the editor. Setting this to true will
// show a guide at the 'preferred_line_length' value if softwrap is set to
// 'preferred_line_length', and will show any additional guides as specified

View file

@ -1000,6 +1000,11 @@ impl CompletionsMenu {
project: Option<ModelHandle<Project>>,
cx: &mut ViewContext<Editor>,
) {
let settings = settings::get::<EditorSettings>(cx);
if !settings.show_completion_documentation {
return;
}
let Some(project) = project else {
return;
};
@ -1083,6 +1088,11 @@ impl CompletionsMenu {
project: Option<&ModelHandle<Project>>,
cx: &mut ViewContext<Editor>,
) {
let settings = settings::get::<EditorSettings>(cx);
if !settings.show_completion_documentation {
return;
}
let completion_index = self.matches[self.selected_item].candidate_id;
let Some(project) = project else {
return;
@ -1241,6 +1251,9 @@ impl CompletionsMenu {
) -> AnyElement<Editor> {
enum CompletionTag {}
let settings = settings::get::<EditorSettings>(cx);
let show_completion_documentation = settings.show_completion_documentation;
let widest_completion_ix = self
.matches
.iter()
@ -1252,7 +1265,9 @@ impl CompletionsMenu {
let mut len = completion.label.text.chars().count();
if let Some(Documentation::SingleLine(text)) = documentation {
len += text.chars().count();
if show_completion_documentation {
len += text.chars().count();
}
}
len
@ -1273,7 +1288,12 @@ impl CompletionsMenu {
let item_ix = start_ix + ix;
let candidate_id = mat.candidate_id;
let completion = &completions_guard[candidate_id];
let documentation = &completion.documentation;
let documentation = if show_completion_documentation {
&completion.documentation
} else {
&None
};
items.push(
MouseEventHandler::new::<CompletionTag, _>(

View file

@ -7,6 +7,7 @@ pub struct EditorSettings {
pub cursor_blink: bool,
pub hover_popover_enabled: bool,
pub show_completions_on_input: bool,
pub show_completion_documentation: bool,
pub use_on_type_format: bool,
pub scrollbar: Scrollbar,
pub relative_line_numbers: bool,
@ -33,6 +34,7 @@ pub struct EditorSettingsContent {
pub cursor_blink: Option<bool>,
pub hover_popover_enabled: Option<bool>,
pub show_completions_on_input: Option<bool>,
pub show_completion_documentation: Option<bool>,
pub use_on_type_format: Option<bool>,
pub scrollbar: Option<ScrollbarContent>,
pub relative_line_numbers: Option<bool>,