parent
39d45bcbc1
commit
5bd7eaa173
35 changed files with 99 additions and 89 deletions
|
@ -250,7 +250,7 @@ pub async fn stream_completion(
|
|||
.map(|output| output.0)
|
||||
}
|
||||
|
||||
/// https://docs.anthropic.com/en/api/rate-limits#response-headers
|
||||
/// <https://docs.anthropic.com/en/api/rate-limits#response-headers>
|
||||
#[derive(Debug)]
|
||||
pub struct RateLimitInfo {
|
||||
pub requests_limit: usize,
|
||||
|
@ -626,7 +626,7 @@ pub struct ApiError {
|
|||
}
|
||||
|
||||
/// An Anthropic API error code.
|
||||
/// https://docs.anthropic.com/en/api/errors#http-errors
|
||||
/// <https://docs.anthropic.com/en/api/errors#http-errors>
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy, EnumString)]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
pub enum ApiErrorCode {
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::sync::LazyLock;
|
|||
|
||||
/// Returns whether the given country code is supported by Anthropic.
|
||||
///
|
||||
/// https://www.anthropic.com/supported-countries
|
||||
/// <https://www.anthropic.com/supported-countries>
|
||||
pub fn is_supported_country(country_code: &str) -> bool {
|
||||
SUPPORTED_COUNTRIES.contains(&country_code)
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ use assistant_slash_command::{AfterCompletion, SlashCommandLine, SlashCommandWor
|
|||
use editor::{CompletionProvider, Editor};
|
||||
use fuzzy::{match_strings, StringMatchCandidate};
|
||||
use gpui::{App, Context, Entity, Task, WeakEntity, Window};
|
||||
use language::{Anchor, Buffer, Documentation, LanguageServerId, ToPoint};
|
||||
use language::{Anchor, Buffer, CompletionDocumentation, LanguageServerId, ToPoint};
|
||||
use parking_lot::Mutex;
|
||||
use project::CompletionIntent;
|
||||
use rope::Point;
|
||||
|
@ -120,7 +120,9 @@ impl SlashCommandCompletionProvider {
|
|||
});
|
||||
Some(project::Completion {
|
||||
old_range: name_range.clone(),
|
||||
documentation: Some(Documentation::SingleLine(command.description())),
|
||||
documentation: Some(CompletionDocumentation::SingleLine(
|
||||
command.description(),
|
||||
)),
|
||||
new_text,
|
||||
label: command.label(cx),
|
||||
server_id: LanguageServerId(0),
|
||||
|
|
|
@ -434,7 +434,7 @@ pub struct LegacyAssistantSettingsContent {
|
|||
pub default_open_ai_model: Option<OpenAiModel>,
|
||||
/// OpenAI API base URL to use when creating new chats.
|
||||
///
|
||||
/// Default: https://api.openai.com/v1
|
||||
/// Default: <https://api.openai.com/v1>
|
||||
pub openai_api_url: Option<String>,
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ use gpui::{
|
|||
Size, StrikethroughStyle, StyledText, UniformListScrollHandle, WeakEntity,
|
||||
};
|
||||
use language::Buffer;
|
||||
use language::{CodeLabel, Documentation};
|
||||
use language::{CodeLabel, CompletionDocumentation};
|
||||
use lsp::LanguageServerId;
|
||||
use multi_buffer::{Anchor, ExcerptId};
|
||||
use ordered_float::OrderedFloat;
|
||||
|
@ -474,7 +474,7 @@ impl CompletionsMenu {
|
|||
let documentation = &completion.documentation;
|
||||
|
||||
let mut len = completion.label.text.chars().count();
|
||||
if let Some(Documentation::SingleLine(text)) = documentation {
|
||||
if let Some(CompletionDocumentation::SingleLine(text)) = documentation {
|
||||
if show_completion_documentation {
|
||||
len += text.chars().count();
|
||||
}
|
||||
|
@ -558,7 +558,9 @@ impl CompletionsMenu {
|
|||
StyledText::new(completion.label.text.clone())
|
||||
.with_highlights(&style.text, highlights);
|
||||
let documentation_label =
|
||||
if let Some(Documentation::SingleLine(text)) = documentation {
|
||||
if let Some(CompletionDocumentation::SingleLine(text)) =
|
||||
documentation
|
||||
{
|
||||
if text.trim().is_empty() {
|
||||
None
|
||||
} else {
|
||||
|
@ -710,20 +712,23 @@ impl CompletionsMenu {
|
|||
.documentation
|
||||
.as_ref()?
|
||||
{
|
||||
Documentation::MultiLinePlainText(text) => {
|
||||
CompletionDocumentation::MultiLinePlainText(text) => {
|
||||
div().child(SharedString::from(text.clone()))
|
||||
}
|
||||
Documentation::MultiLineMarkdown(parsed) if !parsed.text.is_empty() => div()
|
||||
.child(render_parsed_markdown(
|
||||
CompletionDocumentation::MultiLineMarkdown(parsed)
|
||||
if !parsed.text.is_empty() =>
|
||||
{
|
||||
div().child(render_parsed_markdown(
|
||||
"completions_markdown",
|
||||
parsed,
|
||||
&style,
|
||||
workspace,
|
||||
cx,
|
||||
)),
|
||||
Documentation::MultiLineMarkdown(_) => return None,
|
||||
Documentation::SingleLine(_) => return None,
|
||||
Documentation::Undocumented => return None,
|
||||
))
|
||||
}
|
||||
CompletionDocumentation::MultiLineMarkdown(_) => return None,
|
||||
CompletionDocumentation::SingleLine(_) => return None,
|
||||
CompletionDocumentation::Undocumented => return None,
|
||||
}
|
||||
}
|
||||
CompletionEntry::InlineCompletionHint(InlineCompletionMenuHint::Loaded { text }) => {
|
||||
|
|
|
@ -96,9 +96,9 @@ use itertools::Itertools;
|
|||
use language::{
|
||||
language_settings::{self, all_language_settings, language_settings, InlayHintSettings},
|
||||
markdown, point_from_lsp, AutoindentMode, BracketPair, Buffer, Capability, CharKind, CodeLabel,
|
||||
CursorShape, Diagnostic, Documentation, EditPreview, HighlightedText, IndentKind, IndentSize,
|
||||
Language, OffsetRangeExt, Point, Selection, SelectionGoal, TextObject, TransactionId,
|
||||
TreeSitterOptions,
|
||||
CompletionDocumentation, CursorShape, Diagnostic, EditPreview, HighlightedText, IndentKind,
|
||||
IndentSize, Language, OffsetRangeExt, Point, Selection, SelectionGoal, TextObject,
|
||||
TransactionId, TreeSitterOptions,
|
||||
};
|
||||
use language::{point_to_lsp, BufferRow, CharClassifier, Runnable, RunnableRange};
|
||||
use linked_editing_ranges::refresh_linked_ranges;
|
||||
|
@ -14723,7 +14723,10 @@ fn snippet_completions(
|
|||
filter_range: 0..matching_prefix.len(),
|
||||
},
|
||||
server_id: LanguageServerId(usize::MAX),
|
||||
documentation: snippet.description.clone().map(Documentation::SingleLine),
|
||||
documentation: snippet
|
||||
.description
|
||||
.clone()
|
||||
.map(CompletionDocumentation::SingleLine),
|
||||
lsp_completion: lsp::CompletionItem {
|
||||
label: snippet.prefix.first().unwrap().clone(),
|
||||
kind: Some(CompletionItemKind::SNIPPET),
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::sync::LazyLock;
|
|||
|
||||
/// Returns whether the given country code is supported by Google Gemini.
|
||||
///
|
||||
/// https://ai.google.dev/gemini-api/docs/available-regions
|
||||
/// <https://ai.google.dev/gemini-api/docs/available-regions>
|
||||
pub fn is_supported_country(country_code: &str) -> bool {
|
||||
SUPPORTED_COUNTRIES.contains(&country_code)
|
||||
}
|
||||
|
|
|
@ -1418,7 +1418,7 @@ impl App {
|
|||
}
|
||||
|
||||
/// Dispatch an action to the currently active window or global action handler
|
||||
/// See [action::Action] for more information on how actions work
|
||||
/// See [`crate::Action`] for more information on how actions work
|
||||
pub fn dispatch_action(&mut self, action: &dyn Action) {
|
||||
if let Some(active_window) = self.active_window() {
|
||||
active_window
|
||||
|
|
|
@ -559,8 +559,8 @@ pub(crate) enum BackgroundTag {
|
|||
/// A color space for color interpolation.
|
||||
///
|
||||
/// References:
|
||||
/// - https://developer.mozilla.org/en-US/docs/Web/CSS/color-interpolation-method
|
||||
/// - https://www.w3.org/TR/css-color-4/#typedef-color-space
|
||||
/// - <https://developer.mozilla.org/en-US/docs/Web/CSS/color-interpolation-method>
|
||||
/// - <https://www.w3.org/TR/css-color-4/#typedef-color-space>
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Default)]
|
||||
#[repr(C)]
|
||||
pub enum ColorSpace {
|
||||
|
@ -622,7 +622,7 @@ pub fn pattern_slash(color: Hsla) -> Background {
|
|||
///
|
||||
/// The `angle` is in degrees value in the range 0.0 to 360.0.
|
||||
///
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/linear-gradient
|
||||
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/linear-gradient>
|
||||
pub fn linear_gradient(
|
||||
angle: f32,
|
||||
from: impl Into<LinearColorStop>,
|
||||
|
@ -638,7 +638,7 @@ pub fn linear_gradient(
|
|||
|
||||
/// A color stop in a linear gradient.
|
||||
///
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/linear-gradient#linear-color-stop
|
||||
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/linear-gradient#linear-color-stop>
|
||||
#[derive(Debug, Clone, Copy, Default, PartialEq)]
|
||||
#[repr(C)]
|
||||
pub struct LinearColorStop {
|
||||
|
@ -671,7 +671,7 @@ impl LinearColorStop {
|
|||
impl Background {
|
||||
/// Use specified color space for color interpolation.
|
||||
///
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/CSS/color-interpolation-method
|
||||
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/color-interpolation-method>
|
||||
pub fn color_space(mut self, color_space: ColorSpace) -> Self {
|
||||
self.color_space = color_space;
|
||||
self
|
||||
|
|
|
@ -48,10 +48,10 @@
|
|||
//! complex applications:
|
||||
//!
|
||||
//! - Actions are user-defined structs that are used for converting keystrokes into logical operations in your UI.
|
||||
//! Use this for implementing keyboard shortcuts, such as cmd-q. See the [`action`] module for more information.
|
||||
//! Use this for implementing keyboard shortcuts, such as cmd-q (See `action` module for more information).
|
||||
//! - Platform services, such as `quit the app` or `open a URL` are available as methods on the [`app::App`].
|
||||
//! - An async executor that is integrated with the platform's event loop. See the [`executor`] module for more information.,
|
||||
//! - The [gpui::test] macro provides a convenient way to write tests for your GPUI applications. Tests also have their
|
||||
//! - The [`gpui::test`](test) macro provides a convenient way to write tests for your GPUI applications. Tests also have their
|
||||
//! own kind of context, a [`TestAppContext`] which provides ways of simulating common platform input. See [`app::test_context`]
|
||||
//! and [`test`] modules for more details.
|
||||
//!
|
||||
|
|
|
@ -773,7 +773,7 @@ impl crate::Keystroke {
|
|||
|
||||
/**
|
||||
* Returns which symbol the dead key represents
|
||||
* https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values#dead_keycodes_for_linux
|
||||
* <https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values#dead_keycodes_for_linux>
|
||||
*/
|
||||
pub fn underlying_dead_key(keysym: Keysym) -> Option<String> {
|
||||
match keysym {
|
||||
|
|
|
@ -16,7 +16,7 @@ impl SharedString {
|
|||
Self(ArcCow::Borrowed(str))
|
||||
}
|
||||
|
||||
/// Creates a [`SharedString`] from anything that can become an Arc<str>
|
||||
/// Creates a [`SharedString`] from anything that can become an `Arc<str>`
|
||||
pub fn new(str: impl Into<Arc<str>>) -> Self {
|
||||
SharedString(ArcCow::Owned(str.into()))
|
||||
}
|
||||
|
|
|
@ -143,7 +143,7 @@ pub fn box_shadow_style_methods(input: TokenStream) -> TokenStream {
|
|||
styles::box_shadow_style_methods(input)
|
||||
}
|
||||
|
||||
/// #[gpui::test] can be used to annotate test functions that run with GPUI support.
|
||||
/// `#[gpui::test]` can be used to annotate test functions that run with GPUI support.
|
||||
/// it supports both synchronous and asynchronous tests, and can provide you with
|
||||
/// as many `TestAppContext` instances as you need.
|
||||
/// The output contains a `#[test]` annotation so this can be used with any existing
|
||||
|
@ -160,7 +160,7 @@ pub fn box_shadow_style_methods(input: TokenStream) -> TokenStream {
|
|||
/// Using the same `StdRng` for behavior in your test will allow you to exercise a wide
|
||||
/// variety of scenarios and interleavings just by changing the seed.
|
||||
///
|
||||
/// #[gpui::test] also takes three different arguments:
|
||||
/// `#[gpui::test]` also takes three different arguments:
|
||||
/// - `#[gpui::test(iterations=10)]` will run the test ten times with a different initial SEED.
|
||||
/// - `#[gpui::test(retries=3)]` will run the test up to four times if it fails to try and make it pass.
|
||||
/// - `#[gpui::test(on_failure="crate::test::report_failure")]` will call the specified function after the
|
||||
|
|
|
@ -8,7 +8,7 @@ use bytes::Bytes;
|
|||
use futures::AsyncRead;
|
||||
|
||||
/// Based on the implementation of AsyncBody in
|
||||
/// https://github.com/sagebind/isahc/blob/5c533f1ef4d6bdf1fd291b5103c22110f41d0bf0/src/body/mod.rs
|
||||
/// <https://github.com/sagebind/isahc/blob/5c533f1ef4d6bdf1fd291b5103c22110f41d0bf0/src/body/mod.rs>.
|
||||
pub struct AsyncBody(pub Inner);
|
||||
|
||||
pub enum Inner {
|
||||
|
|
|
@ -236,36 +236,35 @@ pub async fn prepare_completion_documentation(
|
|||
documentation: &lsp::Documentation,
|
||||
language_registry: &Arc<LanguageRegistry>,
|
||||
language: Option<Arc<Language>>,
|
||||
) -> Documentation {
|
||||
) -> CompletionDocumentation {
|
||||
match documentation {
|
||||
lsp::Documentation::String(text) => {
|
||||
if text.lines().count() <= 1 {
|
||||
Documentation::SingleLine(text.clone())
|
||||
CompletionDocumentation::SingleLine(text.clone())
|
||||
} else {
|
||||
Documentation::MultiLinePlainText(text.clone())
|
||||
CompletionDocumentation::MultiLinePlainText(text.clone())
|
||||
}
|
||||
}
|
||||
|
||||
lsp::Documentation::MarkupContent(lsp::MarkupContent { kind, value }) => match kind {
|
||||
lsp::MarkupKind::PlainText => {
|
||||
if value.lines().count() <= 1 {
|
||||
Documentation::SingleLine(value.clone())
|
||||
CompletionDocumentation::SingleLine(value.clone())
|
||||
} else {
|
||||
Documentation::MultiLinePlainText(value.clone())
|
||||
CompletionDocumentation::MultiLinePlainText(value.clone())
|
||||
}
|
||||
}
|
||||
|
||||
lsp::MarkupKind::Markdown => {
|
||||
let parsed = parse_markdown(value, Some(language_registry), language).await;
|
||||
Documentation::MultiLineMarkdown(parsed)
|
||||
CompletionDocumentation::MultiLineMarkdown(parsed)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Documentation associated with a [`Completion`].
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum Documentation {
|
||||
pub enum CompletionDocumentation {
|
||||
/// There is no documentation for this completion.
|
||||
Undocumented,
|
||||
/// A single line of documentation.
|
||||
|
|
|
@ -266,7 +266,7 @@ impl std::fmt::Debug for ExcerptInfo {
|
|||
}
|
||||
}
|
||||
|
||||
/// A boundary between [`Excerpt`]s in a [`MultiBuffer`]
|
||||
/// A boundary between `Excerpt`s in a [`MultiBuffer`]
|
||||
#[derive(Debug)]
|
||||
pub struct ExcerptBoundary {
|
||||
pub prev: Option<ExcerptInfo>,
|
||||
|
@ -312,7 +312,7 @@ struct Excerpt {
|
|||
has_trailing_newline: bool,
|
||||
}
|
||||
|
||||
/// A public view into an [`Excerpt`] in a [`MultiBuffer`].
|
||||
/// A public view into an `Excerpt` in a [`MultiBuffer`].
|
||||
///
|
||||
/// Contains methods for getting the [`Buffer`] of the excerpt,
|
||||
/// as well as mapping offsets to/from buffer and multibuffer coordinates.
|
||||
|
@ -332,7 +332,7 @@ struct ExcerptIdMapping {
|
|||
locator: Locator,
|
||||
}
|
||||
|
||||
/// A range of text from a single [`Buffer`], to be shown as an [`Excerpt`].
|
||||
/// A range of text from a single [`Buffer`], to be shown as an `Excerpt`.
|
||||
/// These ranges are relative to the buffer itself
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
|
||||
pub struct ExcerptRange<T> {
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::sync::LazyLock;
|
|||
|
||||
/// Returns whether the given country code is supported by OpenAI.
|
||||
///
|
||||
/// https://platform.openai.com/docs/supported-countries
|
||||
/// <https://platform.openai.com/docs/supported-countries>
|
||||
pub fn is_supported_country(country_code: &str) -> bool {
|
||||
SUPPORTED_COUNTRIES.contains(&country_code)
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ use language::{
|
|||
markdown, point_to_lsp, prepare_completion_documentation,
|
||||
proto::{deserialize_anchor, deserialize_version, serialize_anchor, serialize_version},
|
||||
range_from_lsp, range_to_lsp, Bias, Buffer, BufferSnapshot, CachedLspAdapter, CodeLabel,
|
||||
Diagnostic, DiagnosticEntry, DiagnosticSet, Diff, Documentation, File as _, Language,
|
||||
CompletionDocumentation, Diagnostic, DiagnosticEntry, DiagnosticSet, Diff, File as _, Language,
|
||||
LanguageName, LanguageRegistry, LanguageServerBinaryStatus, LanguageToolchainStore, LocalFile,
|
||||
LspAdapter, LspAdapterDelegate, Patch, PointUtf16, TextBufferSnapshot, ToOffset, ToPointUtf16,
|
||||
Transaction, Unclipped,
|
||||
|
@ -4359,7 +4359,7 @@ impl LspStore {
|
|||
} else {
|
||||
let mut completions = completions.borrow_mut();
|
||||
let completion = &mut completions[completion_index];
|
||||
completion.documentation = Some(Documentation::Undocumented);
|
||||
completion.documentation = Some(CompletionDocumentation::Undocumented);
|
||||
}
|
||||
|
||||
// NB: Zed does not have `details` inside the completion resolve capabilities, but certain language servers violate the spec and do not return `details` immediately, e.g. https://github.com/yioneko/vtsls/issues/213
|
||||
|
@ -4434,16 +4434,16 @@ impl LspStore {
|
|||
let lsp_completion = serde_json::from_slice(&response.lsp_completion)?;
|
||||
|
||||
let documentation = if response.documentation.is_empty() {
|
||||
Documentation::Undocumented
|
||||
CompletionDocumentation::Undocumented
|
||||
} else if response.documentation_is_markdown {
|
||||
Documentation::MultiLineMarkdown(
|
||||
CompletionDocumentation::MultiLineMarkdown(
|
||||
markdown::parse_markdown(&response.documentation, Some(&language_registry), None)
|
||||
.await,
|
||||
)
|
||||
} else if response.documentation.lines().count() <= 1 {
|
||||
Documentation::SingleLine(response.documentation)
|
||||
CompletionDocumentation::SingleLine(response.documentation)
|
||||
} else {
|
||||
Documentation::MultiLinePlainText(response.documentation)
|
||||
CompletionDocumentation::MultiLinePlainText(response.documentation)
|
||||
};
|
||||
|
||||
let mut completions = completions.borrow_mut();
|
||||
|
|
|
@ -56,9 +56,9 @@ use gpui::{
|
|||
use itertools::Itertools;
|
||||
use language::{
|
||||
language_settings::InlayHintKind, proto::split_operations, Buffer, BufferEvent,
|
||||
CachedLspAdapter, Capability, CodeLabel, Documentation, File as _, Language, LanguageName,
|
||||
LanguageRegistry, PointUtf16, ToOffset, ToPointUtf16, Toolchain, ToolchainList, Transaction,
|
||||
Unclipped,
|
||||
CachedLspAdapter, Capability, CodeLabel, CompletionDocumentation, File as _, Language,
|
||||
LanguageName, LanguageRegistry, PointUtf16, ToOffset, ToPointUtf16, Toolchain, ToolchainList,
|
||||
Transaction, Unclipped,
|
||||
};
|
||||
use lsp::{
|
||||
CodeActionKind, CompletionContext, CompletionItemKind, DocumentHighlightKind, LanguageServer,
|
||||
|
@ -368,7 +368,7 @@ pub struct Completion {
|
|||
/// The id of the language server that produced this completion.
|
||||
pub server_id: LanguageServerId,
|
||||
/// The documentation for this completion.
|
||||
pub documentation: Option<Documentation>,
|
||||
pub documentation: Option<CompletionDocumentation>,
|
||||
/// The raw completion provided by the language server.
|
||||
pub lsp_completion: lsp::CompletionItem,
|
||||
/// Whether this completion has been resolved, to ensure it happens once per completion.
|
||||
|
|
|
@ -53,11 +53,6 @@ pub struct AppVersion;
|
|||
|
||||
impl AppVersion {
|
||||
/// Initializes the global [`AppVersion`].
|
||||
///
|
||||
/// Attempts to read the version number from the following locations, in order:
|
||||
/// 1. the `ZED_APP_VERSION` environment variable,
|
||||
/// 2. the [`AppContext::app_metadata`],
|
||||
/// 3. the passed in `pkg_version`.
|
||||
pub fn init(pkg_version: &str) -> SemanticVersion {
|
||||
if let Ok(from_env) = env::var("ZED_APP_VERSION") {
|
||||
from_env.parse().expect("invalid ZED_APP_VERSION")
|
||||
|
|
|
@ -139,7 +139,7 @@ impl futures::Stream for StreamReader {
|
|||
}
|
||||
}
|
||||
|
||||
/// Implementation from https://docs.rs/tokio-util/0.7.12/src/tokio_util/util/poll_buf.rs.html
|
||||
/// Implementation from <https://docs.rs/tokio-util/0.7.12/src/tokio_util/util/poll_buf.rs.html>
|
||||
/// Specialized for this use case
|
||||
pub fn poll_read_buf(
|
||||
io: &mut Pin<Box<dyn futures::AsyncRead + Send + Sync>>,
|
||||
|
|
|
@ -32,12 +32,13 @@ pub trait Settings: 'static + Send + Sync {
|
|||
/// from the root object.
|
||||
const KEY: Option<&'static str>;
|
||||
|
||||
/// The name of the keys in the [`FileContent`] that should always be written to
|
||||
/// a settings file, even if their value matches the default value.
|
||||
/// The name of the keys in the [`FileContent`](Self::FileContent) that should
|
||||
/// always be written to a settings file, even if their value matches the default
|
||||
/// value.
|
||||
///
|
||||
/// This is useful for tagged [`FileContent`]s where the tag is a "version" field
|
||||
/// that should always be persisted, even if the current user settings match the
|
||||
/// current version of the settings.
|
||||
/// This is useful for tagged [`FileContent`](Self::FileContent)s where the tag
|
||||
/// is a "version" field that should always be persisted, even if the current
|
||||
/// user settings match the current version of the settings.
|
||||
const PRESERVED_KEYS: Option<&'static [&'static str]> = None;
|
||||
|
||||
/// The type that is stored in an individual JSON file.
|
||||
|
|
|
@ -32,7 +32,7 @@ pub trait KeyedItem: Item {
|
|||
|
||||
/// A type that describes the Sum of all [`Item`]s in a subtree of the [`SumTree`]
|
||||
///
|
||||
/// Each Summary type can have multiple [`Dimensions`] that it measures,
|
||||
/// Each Summary type can have multiple [`Dimension`]s that it measures,
|
||||
/// which can be used to navigate the tree
|
||||
pub trait Summary: Clone {
|
||||
type Context;
|
||||
|
|
|
@ -122,7 +122,7 @@ pub struct PathLikeTarget {
|
|||
/// A string inside terminal, potentially useful as a URI that can be opened.
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum MaybeNavigationTarget {
|
||||
/// HTTP, git, etc. string determined by the [`URL_REGEX`] regex.
|
||||
/// HTTP, git, etc. string determined by the `URL_REGEX` regex.
|
||||
Url(String),
|
||||
/// File system path, absolute or relative, existing or not.
|
||||
/// Might have line and column number(s) attached as `file.rs:1:23`
|
||||
|
@ -1910,7 +1910,7 @@ fn content_index_for_mouse(pos: Point<Pixels>, size: &TerminalSize) -> usize {
|
|||
|
||||
/// Converts an 8 bit ANSI color to its GPUI equivalent.
|
||||
/// Accepts `usize` for compatibility with the `alacritty::Colors` interface,
|
||||
/// Other than that use case, should only be called with values in the [0,255] range
|
||||
/// Other than that use case, should only be called with values in the `[0,255]` range
|
||||
pub fn get_color_at_index(index: usize, theme: &Theme) -> Hsla {
|
||||
let colors = theme.colors();
|
||||
|
||||
|
|
|
@ -425,7 +425,7 @@ impl BufferLineHeight {
|
|||
}
|
||||
|
||||
impl ThemeSettings {
|
||||
/// Returns the [AdjustedBufferFontSize].
|
||||
/// Returns the buffer font size.
|
||||
pub fn buffer_font_size(&self) -> Pixels {
|
||||
Self::clamp_font_size(self.buffer_font_size)
|
||||
}
|
||||
|
|
|
@ -349,8 +349,8 @@ impl ButtonCommon for Button {
|
|||
/// Sets a tooltip for the button.
|
||||
///
|
||||
/// This method allows a tooltip to be set for the button. The tooltip is a function that
|
||||
/// takes a mutable reference to a [`WindowContext`] and returns an [`AnyView`]. The tooltip
|
||||
/// is displayed when the user hovers over the button.
|
||||
/// takes a mutable references to [`Window`] and [`App`], and returns an [`AnyView`]. The
|
||||
/// tooltip is displayed when the user hovers over the button.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
|
|
@ -31,7 +31,7 @@ pub struct ContentGroup {
|
|||
}
|
||||
|
||||
impl ContentGroup {
|
||||
/// Creates a new [ContentBox].
|
||||
/// Creates a new [`ContentGroup`].
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
base: div(),
|
||||
|
@ -41,13 +41,13 @@ impl ContentGroup {
|
|||
}
|
||||
}
|
||||
|
||||
/// Removes the border from the [ContentBox].
|
||||
/// Removes the border from the [`ContentGroup`].
|
||||
pub fn borderless(mut self) -> Self {
|
||||
self.border = false;
|
||||
self
|
||||
}
|
||||
|
||||
/// Removes the background fill from the [ContentBox].
|
||||
/// Removes the background fill from the [`ContentGroup`].
|
||||
pub fn unfilled(mut self) -> Self {
|
||||
self.fill = false;
|
||||
self
|
||||
|
|
|
@ -28,7 +28,7 @@ pub enum VectorName {
|
|||
|
||||
/// A vector image, such as an SVG.
|
||||
///
|
||||
/// A [`Vector`] is different from an [`Icon`] in that it is intended
|
||||
/// A [`Vector`] is different from an [`crate::Icon`] in that it is intended
|
||||
/// to be displayed at a specific size, or series of sizes, rather
|
||||
/// than conforming to the standard size of an icon.
|
||||
#[derive(IntoElement)]
|
||||
|
|
|
@ -42,8 +42,9 @@ impl Navigable {
|
|||
}
|
||||
|
||||
/// Add a new entry that can be navigated to via keyboard.
|
||||
/// The order of calls to [Navigable::entry] determines the order of traversal of elements via successive
|
||||
/// uses of [menu:::SelectNext]/[menu::SelectPrev]
|
||||
///
|
||||
/// The order of calls to [Navigable::entry] determines the order of traversal of
|
||||
/// elements via successive uses of `menu:::SelectNext/SelectPrev`
|
||||
pub fn entry(mut self, child: NavigableEntry) -> Self {
|
||||
self.selectable_children.push(child);
|
||||
self
|
||||
|
@ -59,6 +60,7 @@ impl Navigable {
|
|||
.position(|entry| entry.focus_handle.contains_focused(window, cx))
|
||||
}
|
||||
}
|
||||
|
||||
impl RenderOnce for Navigable {
|
||||
fn render(self, _window: &mut Window, _: &mut App) -> impl crate::IntoElement {
|
||||
div()
|
||||
|
|
|
@ -5,6 +5,8 @@ use std::sync::Arc;
|
|||
use crate::prelude::*;
|
||||
|
||||
/// A [`Checkbox`] that has a [`Label`].
|
||||
///
|
||||
/// [`Checkbox`]: crate::components::Checkbox
|
||||
#[derive(IntoElement)]
|
||||
pub struct RadioWithLabel {
|
||||
id: ElementId,
|
||||
|
|
|
@ -22,7 +22,7 @@ pub enum ElevationIndex {
|
|||
EditorSurface,
|
||||
/// A surface that is elevated above the primary surface. but below washes, models, and dragged elements.
|
||||
ElevatedSurface,
|
||||
/// A surface above the [ElevationIndex::Wash] that is used for dialogs, alerts, modals, etc.
|
||||
/// A surface above the [ElevationIndex::ElevatedSurface] that is used for dialogs, alerts, modals, etc.
|
||||
ModalSurface,
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ pub trait StyledTypography: Styled + Sized {
|
|||
self.font_family(ui_font_family)
|
||||
}
|
||||
|
||||
/// Sets the text size using a [`UiTextSize`].
|
||||
/// Sets the text size using a [`TextSize`].
|
||||
fn text_ui_size(self, size: TextSize, cx: &App) -> Self {
|
||||
self.text_size(size.rems(cx))
|
||||
}
|
||||
|
|
|
@ -42,9 +42,9 @@ pub trait StyledExt: Styled + Sized {
|
|||
elevated(self, cx, ElevationIndex::Surface)
|
||||
}
|
||||
|
||||
/// See [`elevation_1`].
|
||||
/// See [`elevation_1`](Self::elevation_1).
|
||||
///
|
||||
/// Renders a borderless version [`elevation_1`].
|
||||
/// Renders a borderless version [`elevation_1`](Self::elevation_1).
|
||||
fn elevation_1_borderless(self, cx: &mut App) -> Self {
|
||||
elevated_borderless(self, cx, ElevationIndex::Surface)
|
||||
}
|
||||
|
@ -58,9 +58,9 @@ pub trait StyledExt: Styled + Sized {
|
|||
elevated(self, cx, ElevationIndex::ElevatedSurface)
|
||||
}
|
||||
|
||||
/// See [`elevation_2`].
|
||||
/// See [`elevation_2`](Self::elevation_2).
|
||||
///
|
||||
/// Renders a borderless version [`elevation_2`].
|
||||
/// Renders a borderless version [`elevation_2`](Self::elevation_2).
|
||||
fn elevation_2_borderless(self, cx: &mut App) -> Self {
|
||||
elevated_borderless(self, cx, ElevationIndex::ElevatedSurface)
|
||||
}
|
||||
|
@ -78,9 +78,9 @@ pub trait StyledExt: Styled + Sized {
|
|||
elevated(self, cx, ElevationIndex::ModalSurface)
|
||||
}
|
||||
|
||||
/// See [`elevation_3`].
|
||||
/// See [`elevation_3`](Self::elevation_3).
|
||||
///
|
||||
/// Renders a borderless version [`elevation_3`].
|
||||
/// Renders a borderless version [`elevation_3`](Self::elevation_3).
|
||||
fn elevation_3_borderless(self, cx: &mut App) -> Self {
|
||||
elevated_borderless(self, cx, ElevationIndex::ModalSurface)
|
||||
}
|
||||
|
|
|
@ -7,8 +7,7 @@
|
|||
//! ## Related Crates:
|
||||
//!
|
||||
//! - [`ui_macros`] - proc_macros support for this crate
|
||||
//! - [`ui_input`] - the single line input component
|
||||
//!
|
||||
//! - `ui_input` - the single line input component
|
||||
|
||||
mod components;
|
||||
pub mod prelude;
|
||||
|
|
|
@ -22,6 +22,8 @@ impl WithRemSize {
|
|||
|
||||
/// Block the mouse from interacting with this element or any of its children
|
||||
/// The fluent API equivalent to [`Interactivity::occlude_mouse`]
|
||||
///
|
||||
/// [`Interactivity::occlude_mouse`]: gpui::Interactivity::occlude_mouse
|
||||
pub fn occlude(mut self) -> Self {
|
||||
self.div = self.div.occlude();
|
||||
self
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue