Don't perform wrapping in completions
This commit is contained in:
parent
fff2d7955e
commit
2b6e8de11f
4 changed files with 43 additions and 8 deletions
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
Bounds, Element, ElementId, LayoutId, Pixels, RenderOnce, SharedString, Size, TextRun,
|
||||
WindowContext, WrappedLine,
|
||||
WhiteSpace, WindowContext, WrappedLine,
|
||||
};
|
||||
use anyhow::anyhow;
|
||||
use parking_lot::{Mutex, MutexGuard};
|
||||
|
@ -159,10 +159,14 @@ impl TextState {
|
|||
let element_state = self.clone();
|
||||
|
||||
move |known_dimensions, available_space| {
|
||||
let wrap_width = known_dimensions.width.or(match available_space.width {
|
||||
crate::AvailableSpace::Definite(x) => Some(x),
|
||||
_ => None,
|
||||
});
|
||||
let wrap_width = if text_style.white_space == WhiteSpace::Normal {
|
||||
known_dimensions.width.or(match available_space.width {
|
||||
crate::AvailableSpace::Definite(x) => Some(x),
|
||||
_ => None,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
if let Some(text_state) = element_state.0.lock().as_ref() {
|
||||
if text_state.size.is_some()
|
||||
|
|
|
@ -128,6 +128,13 @@ pub struct BoxShadow {
|
|||
pub spread_radius: Pixels,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
|
||||
pub enum WhiteSpace {
|
||||
#[default]
|
||||
Normal,
|
||||
Nowrap,
|
||||
}
|
||||
|
||||
#[derive(Refineable, Clone, Debug)]
|
||||
#[refineable(Debug)]
|
||||
pub struct TextStyle {
|
||||
|
@ -139,6 +146,7 @@ pub struct TextStyle {
|
|||
pub font_weight: FontWeight,
|
||||
pub font_style: FontStyle,
|
||||
pub underline: Option<UnderlineStyle>,
|
||||
pub white_space: WhiteSpace,
|
||||
}
|
||||
|
||||
impl Default for TextStyle {
|
||||
|
@ -152,6 +160,7 @@ impl Default for TextStyle {
|
|||
font_weight: FontWeight::default(),
|
||||
font_style: FontStyle::default(),
|
||||
underline: None,
|
||||
white_space: WhiteSpace::Normal,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::{
|
||||
self as gpui, hsla, point, px, relative, rems, AbsoluteLength, AlignItems, CursorStyle,
|
||||
DefiniteLength, Display, Fill, FlexDirection, Hsla, JustifyContent, Length, Position,
|
||||
SharedString, StyleRefinement, Visibility,
|
||||
SharedString, StyleRefinement, Visibility, WhiteSpace,
|
||||
};
|
||||
use crate::{BoxShadow, TextStyleRefinement};
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
|
@ -101,6 +101,24 @@ pub trait Styled: Sized {
|
|||
self
|
||||
}
|
||||
|
||||
/// Sets the whitespace of the element to `normal`.
|
||||
/// [Docs](https://tailwindcss.com/docs/whitespace#normal)
|
||||
fn whitespace_normal(mut self) -> Self {
|
||||
self.text_style()
|
||||
.get_or_insert_with(Default::default)
|
||||
.white_space = Some(WhiteSpace::Normal);
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the whitespace of the element to `nowrap`.
|
||||
/// [Docs](https://tailwindcss.com/docs/whitespace#nowrap)
|
||||
fn whitespace_nowrap(mut self) -> Self {
|
||||
self.text_style()
|
||||
.get_or_insert_with(Default::default)
|
||||
.white_space = Some(WhiteSpace::Nowrap);
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the flex direction of the element to `column`.
|
||||
/// [Docs](https://tailwindcss.com/docs/flex-direction#column)
|
||||
fn flex_col(mut self) -> Self {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue