Implement Editor::single_line
This commit is contained in:
parent
4bf3a4e3d4
commit
3a72f2122a
3 changed files with 25 additions and 21 deletions
|
@ -8,10 +8,11 @@ use crate::{
|
|||
use anyhow::Result;
|
||||
use collections::{BTreeMap, HashMap};
|
||||
use gpui::{
|
||||
black, hsla, point, px, relative, size, transparent_black, Action, AnyElement, BorrowWindow,
|
||||
Bounds, ContentMask, Corners, DispatchContext, DispatchPhase, Edges, Element, ElementId,
|
||||
Entity, Hsla, KeyDownEvent, KeyListener, KeyMatch, Line, Pixels, ScrollWheelEvent, ShapedGlyph,
|
||||
Size, StatefulInteraction, Style, TextRun, TextStyle, TextSystem, ViewContext, WindowContext,
|
||||
black, hsla, point, px, relative, size, transparent_black, Action, AnyElement,
|
||||
BorrowAppContext, BorrowWindow, Bounds, ContentMask, Corners, DispatchContext, DispatchPhase,
|
||||
Edges, Element, ElementId, Entity, Hsla, KeyDownEvent, KeyListener, KeyMatch, Line, Pixels,
|
||||
ScrollWheelEvent, ShapedGlyph, Size, StatefulInteraction, Style, TextRun, TextStyle,
|
||||
TextSystem, ViewContext, WindowContext,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use language::language_settings::ShowWhitespaceSetting;
|
||||
|
@ -1605,7 +1606,7 @@ impl EditorElement {
|
|||
let style = self.style.clone();
|
||||
let font_id = cx.text_system().font_id(&style.text.font()).unwrap();
|
||||
let font_size = style.text.font_size.to_pixels(cx.rem_size());
|
||||
let line_height = (font_size * style.line_height_scalar).round();
|
||||
let line_height = style.text.line_height_in_pixels(cx.rem_size());
|
||||
let em_width = cx
|
||||
.text_system()
|
||||
.typographic_bounds(font_id, font_size, 'm')
|
||||
|
@ -2593,7 +2594,11 @@ impl Element<Editor> for EditorElement {
|
|||
let rem_size = cx.rem_size();
|
||||
let mut style = Style::default();
|
||||
style.size.width = relative(1.).into();
|
||||
style.size.height = relative(1.).into();
|
||||
style.size.height = match editor.mode {
|
||||
EditorMode::SingleLine => self.style.text.line_height_in_pixels(cx.rem_size()).into(),
|
||||
EditorMode::AutoHeight { .. } => todo!(),
|
||||
EditorMode::Full => relative(1.).into(),
|
||||
};
|
||||
cx.request_layout(&style, None)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue