Use defaults for unchanged TextStyle fields (#14918)

This PR updates a number of spots where we were setting all of the
`TextStyle` fields even if we were not changing the values from the
defaults.

We now use `..Default::default()`.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-07-21 11:55:45 -04:00 committed by GitHub
parent e8bcc412b5
commit cb2c334358
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 36 additions and 87 deletions

View file

@ -22,9 +22,9 @@ use futures::{
SinkExt, Stream, StreamExt, SinkExt, Stream, StreamExt,
}; };
use gpui::{ use gpui::{
point, AppContext, EventEmitter, FocusHandle, FocusableView, FontStyle, Global, HighlightStyle, point, AppContext, EventEmitter, FocusHandle, FocusableView, Global, HighlightStyle, Model,
Model, ModelContext, Subscription, Task, TextStyle, UpdateGlobal, View, ViewContext, WeakView, ModelContext, Subscription, Task, TextStyle, UpdateGlobal, View, ViewContext, WeakView,
WhiteSpace, WindowContext, WindowContext,
}; };
use language::{Buffer, Point, Selection, TransactionId}; use language::{Buffer, Point, Selection, TransactionId};
use language_model::{LanguageModelRequest, LanguageModelRequestMessage, Role}; use language_model::{LanguageModelRequest, LanguageModelRequestMessage, Role};
@ -1864,12 +1864,8 @@ impl PromptEditor {
font_features: settings.ui_font.features.clone(), font_features: settings.ui_font.features.clone(),
font_size: rems(0.875).into(), font_size: rems(0.875).into(),
font_weight: settings.ui_font.weight, font_weight: settings.ui_font.weight,
font_style: FontStyle::Normal,
line_height: relative(1.3), line_height: relative(1.3),
background_color: None, ..Default::default()
underline: None,
strikethrough: None,
white_space: WhiteSpace::Normal,
}; };
EditorElement::new( EditorElement::new(
&self.editor, &self.editor,

View file

@ -13,8 +13,8 @@ use editor::{
use fs::Fs; use fs::Fs;
use futures::{channel::mpsc, SinkExt, StreamExt}; use futures::{channel::mpsc, SinkExt, StreamExt};
use gpui::{ use gpui::{
AppContext, Context, EventEmitter, FocusHandle, FocusableView, FontStyle, FontWeight, Global, AppContext, Context, EventEmitter, FocusHandle, FocusableView, FontWeight, Global, Model,
Model, ModelContext, Subscription, Task, TextStyle, UpdateGlobal, View, WeakView, WhiteSpace, ModelContext, Subscription, Task, TextStyle, UpdateGlobal, View, WeakView,
}; };
use language::Buffer; use language::Buffer;
use language_model::{LanguageModelRequest, LanguageModelRequestMessage, Role}; use language_model::{LanguageModelRequest, LanguageModelRequestMessage, Role};
@ -946,12 +946,8 @@ impl PromptEditor {
font_features: settings.ui_font.features.clone(), font_features: settings.ui_font.features.clone(),
font_size: rems(0.875).into(), font_size: rems(0.875).into(),
font_weight: FontWeight::NORMAL, font_weight: FontWeight::NORMAL,
font_style: FontStyle::Normal,
line_height: relative(1.3), line_height: relative(1.3),
background_color: None, ..Default::default()
underline: None,
strikethrough: None,
white_space: WhiteSpace::Normal,
}; };
EditorElement::new( EditorElement::new(
&self.editor, &self.editor,

View file

@ -6,7 +6,7 @@ use editor::{AnchorRangeExt, CompletionProvider, Editor, EditorElement, EditorSt
use fuzzy::{StringMatch, StringMatchCandidate}; use fuzzy::{StringMatch, StringMatchCandidate};
use gpui::{ use gpui::{
AsyncWindowContext, FocusableView, FontStyle, FontWeight, HighlightStyle, IntoElement, Model, AsyncWindowContext, FocusableView, FontStyle, FontWeight, HighlightStyle, IntoElement, Model,
Render, Task, TextStyle, View, ViewContext, WeakView, WhiteSpace, Render, Task, TextStyle, View, ViewContext, WeakView,
}; };
use language::{ use language::{
language_settings::SoftWrap, Anchor, Buffer, BufferSnapshot, CodeLabel, LanguageRegistry, language_settings::SoftWrap, Anchor, Buffer, BufferSnapshot, CodeLabel, LanguageRegistry,
@ -537,10 +537,7 @@ impl Render for MessageEditor {
font_weight: settings.ui_font.weight, font_weight: settings.ui_font.weight,
font_style: FontStyle::Normal, font_style: FontStyle::Normal,
line_height: relative(1.3), line_height: relative(1.3),
background_color: None, ..Default::default()
underline: None,
strikethrough: None,
white_space: WhiteSpace::Normal,
}; };
div() div()

View file

@ -16,7 +16,7 @@ use gpui::{
EventEmitter, FocusHandle, FocusableView, FontStyle, InteractiveElement, IntoElement, EventEmitter, FocusHandle, FocusableView, FontStyle, InteractiveElement, IntoElement,
ListOffset, ListState, Model, MouseDownEvent, ParentElement, Pixels, Point, PromptLevel, ListOffset, ListState, Model, MouseDownEvent, ParentElement, Pixels, Point, PromptLevel,
Render, SharedString, Styled, Subscription, Task, TextStyle, View, ViewContext, VisualContext, Render, SharedString, Styled, Subscription, Task, TextStyle, View, ViewContext, VisualContext,
WeakView, WhiteSpace, WeakView,
}; };
use menu::{Cancel, Confirm, SecondaryConfirm, SelectNext, SelectPrev}; use menu::{Cancel, Confirm, SecondaryConfirm, SelectNext, SelectPrev};
use project::{Fs, Project}; use project::{Fs, Project};
@ -2194,10 +2194,7 @@ impl CollabPanel {
font_weight: settings.ui_font.weight, font_weight: settings.ui_font.weight,
font_style: FontStyle::Normal, font_style: FontStyle::Normal,
line_height: relative(1.3), line_height: relative(1.3),
background_color: None, ..Default::default()
underline: None,
strikethrough: None,
white_space: WhiteSpace::Normal,
}; };
EditorElement::new( EditorElement::new(

View file

@ -4,7 +4,7 @@ use anthropic::{stream_completion, Model as AnthropicModel, Request, RequestMess
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use editor::{Editor, EditorElement, EditorStyle}; use editor::{Editor, EditorElement, EditorStyle};
use futures::{future::BoxFuture, stream::BoxStream, FutureExt, StreamExt}; use futures::{future::BoxFuture, stream::BoxStream, FutureExt, StreamExt};
use gpui::{AnyView, AppContext, FontStyle, Task, TextStyle, View, WhiteSpace}; use gpui::{AnyView, AppContext, Task, TextStyle, View};
use http::HttpClient; use http::HttpClient;
use language_model::Role; use language_model::Role;
use settings::Settings; use settings::Settings;
@ -257,12 +257,8 @@ impl AuthenticationPrompt {
font_features: settings.ui_font.features.clone(), font_features: settings.ui_font.features.clone(),
font_size: rems(0.875).into(), font_size: rems(0.875).into(),
font_weight: settings.ui_font.weight, font_weight: settings.ui_font.weight,
font_style: FontStyle::Normal,
line_height: relative(1.3), line_height: relative(1.3),
background_color: None, ..Default::default()
underline: None,
strikethrough: None,
white_space: WhiteSpace::Normal,
}; };
EditorElement::new( EditorElement::new(
&self.api_key, &self.api_key,

View file

@ -3,7 +3,7 @@ use crate::LanguageModelCompletionProvider;
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use editor::{Editor, EditorElement, EditorStyle}; use editor::{Editor, EditorElement, EditorStyle};
use futures::{future::BoxFuture, stream::BoxStream, FutureExt, StreamExt}; use futures::{future::BoxFuture, stream::BoxStream, FutureExt, StreamExt};
use gpui::{AnyView, AppContext, FontStyle, Task, TextStyle, View, WhiteSpace}; use gpui::{AnyView, AppContext, Task, TextStyle, View};
use http::HttpClient; use http::HttpClient;
use language_model::{CloudModel, LanguageModel, LanguageModelRequest, Role}; use language_model::{CloudModel, LanguageModel, LanguageModelRequest, Role};
use open_ai::Model as OpenAiModel; use open_ai::Model as OpenAiModel;
@ -298,12 +298,8 @@ impl AuthenticationPrompt {
font_features: settings.ui_font.features.clone(), font_features: settings.ui_font.features.clone(),
font_size: rems(0.875).into(), font_size: rems(0.875).into(),
font_weight: settings.ui_font.weight, font_weight: settings.ui_font.weight,
font_style: FontStyle::Normal,
line_height: relative(1.3), line_height: relative(1.3),
background_color: None, ..Default::default()
underline: None,
strikethrough: None,
white_space: WhiteSpace::Normal,
}; };
EditorElement::new( EditorElement::new(
&self.api_key, &self.api_key,

View file

@ -69,11 +69,11 @@ use gpui::{
div, impl_actions, point, prelude::*, px, relative, size, uniform_list, Action, AnyElement, div, impl_actions, point, prelude::*, px, relative, size, uniform_list, Action, AnyElement,
AppContext, AsyncWindowContext, AvailableSpace, BackgroundExecutor, Bounds, ClipboardItem, AppContext, AsyncWindowContext, AvailableSpace, BackgroundExecutor, Bounds, ClipboardItem,
Context, DispatchPhase, ElementId, EntityId, EventEmitter, FocusHandle, FocusOutEvent, Context, DispatchPhase, ElementId, EntityId, EventEmitter, FocusHandle, FocusOutEvent,
FocusableView, FontId, FontStyle, FontWeight, HighlightStyle, Hsla, InteractiveText, FocusableView, FontId, FontWeight, HighlightStyle, Hsla, InteractiveText, KeyContext,
KeyContext, ListSizingBehavior, Model, MouseButton, PaintQuad, ParentElement, Pixels, Render, ListSizingBehavior, Model, MouseButton, PaintQuad, ParentElement, Pixels, Render, SharedString,
SharedString, Size, StrikethroughStyle, Styled, StyledText, Subscription, Task, TextStyle, Size, StrikethroughStyle, Styled, StyledText, Subscription, Task, TextStyle, UnderlineStyle,
UnderlineStyle, UniformListScrollHandle, View, ViewContext, ViewInputHandler, VisualContext, UniformListScrollHandle, View, ViewContext, ViewInputHandler, VisualContext, WeakFocusHandle,
WeakFocusHandle, WeakView, WhiteSpace, WindowContext, WeakView, WindowContext,
}; };
use highlight_matching_bracket::refresh_matching_bracket_highlights; use highlight_matching_bracket::refresh_matching_bracket_highlights;
use hover_popover::{hide_hover, HoverState}; use hover_popover::{hide_hover, HoverState};
@ -12438,12 +12438,8 @@ impl Render for Editor {
font_features: settings.ui_font.features.clone(), font_features: settings.ui_font.features.clone(),
font_size: rems(0.875).into(), font_size: rems(0.875).into(),
font_weight: settings.ui_font.weight, font_weight: settings.ui_font.weight,
font_style: FontStyle::Normal,
line_height: relative(settings.buffer_line_height.value()), line_height: relative(settings.buffer_line_height.value()),
background_color: None, ..Default::default()
underline: None,
strikethrough: None,
white_space: WhiteSpace::Normal,
}, },
EditorMode::Full => TextStyle { EditorMode::Full => TextStyle {
color: cx.theme().colors().editor_foreground, color: cx.theme().colors().editor_foreground,
@ -12451,12 +12447,8 @@ impl Render for Editor {
font_features: settings.buffer_font.features.clone(), font_features: settings.buffer_font.features.clone(),
font_size: settings.buffer_font_size(cx).into(), font_size: settings.buffer_font_size(cx).into(),
font_weight: settings.buffer_font.weight, font_weight: settings.buffer_font.weight,
font_style: FontStyle::Normal,
line_height: relative(settings.buffer_line_height.value()), line_height: relative(settings.buffer_line_height.value()),
background_color: None, ..Default::default()
underline: None,
strikethrough: None,
white_space: WhiteSpace::Normal,
}, },
}; };

View file

@ -14,9 +14,9 @@ use editor::{Editor, EditorElement, EditorStyle};
use extension::{ExtensionManifest, ExtensionOperation, ExtensionStore}; use extension::{ExtensionManifest, ExtensionOperation, ExtensionStore};
use fuzzy::{match_strings, StringMatchCandidate}; use fuzzy::{match_strings, StringMatchCandidate};
use gpui::{ use gpui::{
actions, uniform_list, AppContext, EventEmitter, Flatten, FocusableView, FontStyle, actions, uniform_list, AppContext, EventEmitter, Flatten, FocusableView, InteractiveElement,
InteractiveElement, KeyContext, ParentElement, Render, Styled, Task, TextStyle, KeyContext, ParentElement, Render, Styled, Task, TextStyle, UniformListScrollHandle, View,
UniformListScrollHandle, View, ViewContext, VisualContext, WeakView, WhiteSpace, WindowContext, ViewContext, VisualContext, WeakView, WindowContext,
}; };
use num_format::{Locale, ToFormattedString}; use num_format::{Locale, ToFormattedString};
use project::DirectoryLister; use project::DirectoryLister;
@ -804,12 +804,8 @@ impl ExtensionsPage {
font_features: settings.ui_font.features.clone(), font_features: settings.ui_font.features.clone(),
font_size: rems(0.875).into(), font_size: rems(0.875).into(),
font_weight: settings.ui_font.weight, font_weight: settings.ui_font.weight,
font_style: FontStyle::Normal,
line_height: relative(1.3), line_height: relative(1.3),
background_color: None, ..Default::default()
underline: None,
strikethrough: None,
white_space: WhiteSpace::Normal,
}; };
EditorElement::new( EditorElement::new(

View file

@ -1,8 +1,5 @@
use fuzzy::{StringMatch, StringMatchCandidate}; use fuzzy::{StringMatch, StringMatchCandidate};
use gpui::{ use gpui::{relative, AppContext, BackgroundExecutor, HighlightStyle, StyledText, TextStyle};
relative, AppContext, BackgroundExecutor, FontStyle, HighlightStyle, StyledText, TextStyle,
WhiteSpace,
};
use settings::Settings; use settings::Settings;
use std::ops::Range; use std::ops::Range;
use theme::{color_alpha, ActiveTheme, ThemeSettings}; use theme::{color_alpha, ActiveTheme, ThemeSettings};
@ -167,12 +164,8 @@ pub fn render_item<T>(
font_features: settings.buffer_font.features.clone(), font_features: settings.buffer_font.features.clone(),
font_size: settings.buffer_font_size(cx).into(), font_size: settings.buffer_font_size(cx).into(),
font_weight: settings.buffer_font.weight, font_weight: settings.buffer_font.weight,
font_style: FontStyle::Normal,
line_height: relative(1.), line_height: relative(1.),
background_color: None, ..Default::default()
underline: None,
strikethrough: None,
white_space: WhiteSpace::Normal,
}; };
let highlights = gpui::combine_highlights( let highlights = gpui::combine_highlights(
custom_highlights, custom_highlights,

View file

@ -13,10 +13,9 @@ use editor::{
}; };
use futures::channel::oneshot; use futures::channel::oneshot;
use gpui::{ use gpui::{
actions, div, impl_actions, Action, AppContext, ClickEvent, EventEmitter, FocusableView, actions, div, impl_actions, Action, AppContext, ClickEvent, EventEmitter, FocusableView, Hsla,
FontStyle, Hsla, InteractiveElement as _, IntoElement, KeyContext, ParentElement as _, Render, InteractiveElement as _, IntoElement, KeyContext, ParentElement as _, Render, ScrollHandle,
ScrollHandle, Styled, Subscription, Task, TextStyle, View, ViewContext, VisualContext as _, Styled, Subscription, Task, TextStyle, View, ViewContext, VisualContext as _, WindowContext,
WhiteSpace, WindowContext,
}; };
use project::{ use project::{
search::SearchQuery, search::SearchQuery,
@ -117,12 +116,8 @@ impl BufferSearchBar {
font_features: settings.buffer_font.features.clone(), font_features: settings.buffer_font.features.clone(),
font_size: rems(0.875).into(), font_size: rems(0.875).into(),
font_weight: settings.buffer_font.weight, font_weight: settings.buffer_font.weight,
font_style: FontStyle::Normal,
line_height: relative(1.3), line_height: relative(1.3),
background_color: None, ..Default::default()
underline: None,
strikethrough: None,
white_space: WhiteSpace::Normal,
}; };
EditorElement::new( EditorElement::new(

View file

@ -13,10 +13,9 @@ use editor::{
}; };
use gpui::{ use gpui::{
actions, div, Action, AnyElement, AnyView, AppContext, Context as _, EntityId, EventEmitter, actions, div, Action, AnyElement, AnyView, AppContext, Context as _, EntityId, EventEmitter,
FocusHandle, FocusableView, FontStyle, Global, Hsla, InteractiveElement, IntoElement, FocusHandle, FocusableView, Global, Hsla, InteractiveElement, IntoElement, KeyContext, Model,
KeyContext, Model, ModelContext, ParentElement, Point, Render, SharedString, Styled, ModelContext, ParentElement, Point, Render, SharedString, Styled, Subscription, Task,
Subscription, Task, TextStyle, UpdateGlobal, View, ViewContext, VisualContext, WeakModel, TextStyle, UpdateGlobal, View, ViewContext, VisualContext, WeakModel, WindowContext,
WhiteSpace, WindowContext,
}; };
use menu::Confirm; use menu::Confirm;
use project::{search::SearchQuery, search_history::SearchHistoryCursor, Project, ProjectPath}; use project::{search::SearchQuery, search_history::SearchHistoryCursor, Project, ProjectPath};
@ -1341,12 +1340,8 @@ impl ProjectSearchBar {
font_features: settings.buffer_font.features.clone(), font_features: settings.buffer_font.features.clone(),
font_size: rems(0.875).into(), font_size: rems(0.875).into(),
font_weight: settings.buffer_font.weight, font_weight: settings.buffer_font.weight,
font_style: FontStyle::Normal,
line_height: relative(1.3), line_height: relative(1.3),
background_color: None, ..Default::default()
underline: None,
strikethrough: None,
white_space: WhiteSpace::Normal,
}; };
EditorElement::new( EditorElement::new(