Add option for code context menu items to have dynamic width (#37404)
Follow up to https://github.com/zed-industries/zed/pull/30598 This PR introduces the `display_options` field in the `CompletionResponse`, allowing a code context menu width to be dynamically dictated based on its larger item. This will allow us to have the @-mentions and slash commands completion menus in the agent panel not be bigger than it needs to be. It may also be relevant/useful in the future for other use cases. For now, we set all instances of code context menus to use a fixed width, as defined in the PR linked above, which means this PR shouldn't cause any visual change. Release Notes: - N/A Co-authored-by: Michael Sloan <mgsloan+github@gmail.com>
This commit is contained in:
co-authored by
Michael Sloan
parent
4b96ad3fba
commit
946efb03df
@@ -16,10 +16,10 @@ pub mod lsp_ext_command;
|
||||
pub mod rust_analyzer_ext;
|
||||
|
||||
use crate::{
|
||||
CodeAction, ColorPresentation, Completion, CompletionResponse, CompletionSource,
|
||||
CoreCompletion, DocumentColor, Hover, InlayHint, LocationLink, LspAction, LspPullDiagnostics,
|
||||
ManifestProvidersStore, Project, ProjectItem, ProjectPath, ProjectTransaction,
|
||||
PulledDiagnostics, ResolveState, Symbol,
|
||||
CodeAction, ColorPresentation, Completion, CompletionDisplayOptions, CompletionResponse,
|
||||
CompletionSource, CoreCompletion, DocumentColor, Hover, InlayHint, LocationLink, LspAction,
|
||||
LspPullDiagnostics, ManifestProvidersStore, Project, ProjectItem, ProjectPath,
|
||||
ProjectTransaction, PulledDiagnostics, ResolveState, Symbol,
|
||||
buffer_store::{BufferStore, BufferStoreEvent},
|
||||
environment::ProjectEnvironment,
|
||||
lsp_command::{self, *},
|
||||
@@ -5828,6 +5828,7 @@ impl LspStore {
|
||||
.await;
|
||||
Ok(vec![CompletionResponse {
|
||||
completions,
|
||||
display_options: CompletionDisplayOptions::default(),
|
||||
is_incomplete: completion_response.is_incomplete,
|
||||
}])
|
||||
})
|
||||
@@ -5920,6 +5921,7 @@ impl LspStore {
|
||||
.await;
|
||||
Some(CompletionResponse {
|
||||
completions,
|
||||
display_options: CompletionDisplayOptions::default(),
|
||||
is_incomplete: completion_response.is_incomplete,
|
||||
})
|
||||
});
|
||||
|
||||
@@ -574,11 +574,23 @@ impl std::fmt::Debug for Completion {
|
||||
/// Response from a source of completions.
|
||||
pub struct CompletionResponse {
|
||||
pub completions: Vec<Completion>,
|
||||
pub display_options: CompletionDisplayOptions,
|
||||
/// When false, indicates that the list is complete and so does not need to be re-queried if it
|
||||
/// can be filtered instead.
|
||||
pub is_incomplete: bool,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct CompletionDisplayOptions {
|
||||
pub dynamic_width: bool,
|
||||
}
|
||||
|
||||
impl CompletionDisplayOptions {
|
||||
pub fn merge(&mut self, other: &CompletionDisplayOptions) {
|
||||
self.dynamic_width = self.dynamic_width && other.dynamic_width;
|
||||
}
|
||||
}
|
||||
|
||||
/// Response from language server completion request.
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub(crate) struct CoreCompletionResponse {
|
||||
|
||||
Reference in New Issue
Block a user