Fix single-line editors not working anymore (#10994)

This was introduced with #10979 and was caused by a missing call to
`cx.set_view_id` in `EditorElement`, which is necessary when rendering
`EditorElement` manually instead of via a view.

Release Notes:

- N/A
This commit is contained in:
Antonio Scandurra
2024-04-25 17:04:20 +02:00
committed by GitHub
parent 1cd34fdd9c
commit 11bcfea6d2
+6 -5
View File
@@ -23,11 +23,11 @@ use git::{blame::BlameEntry, diff::DiffHunkStatus, Oid};
use gpui::{
anchored, deferred, div, fill, outline, point, px, quad, relative, size, svg,
transparent_black, Action, AnchorCorner, AnyElement, AvailableSpace, Bounds, ClipboardItem,
ContentMask, Corners, CursorStyle, DispatchPhase, Edges, Element, ElementInputHandler, Hitbox,
Hsla, InteractiveElement, IntoElement, ModifiersChangedEvent, MouseButton, MouseDownEvent,
MouseMoveEvent, MouseUpEvent, PaintQuad, ParentElement, Pixels, ScrollDelta, ScrollWheelEvent,
ShapedLine, SharedString, Size, Stateful, StatefulInteractiveElement, Style, Styled, TextRun,
TextStyle, TextStyleRefinement, View, ViewContext, WeakView, WindowContext,
ContentMask, Corners, CursorStyle, DispatchPhase, Edges, Element, ElementInputHandler, Entity,
Hitbox, Hsla, InteractiveElement, IntoElement, ModifiersChangedEvent, MouseButton,
MouseDownEvent, MouseMoveEvent, MouseUpEvent, PaintQuad, ParentElement, Pixels, ScrollDelta,
ScrollWheelEvent, ShapedLine, SharedString, Size, Stateful, StatefulInteractiveElement, Style,
Styled, TextRun, TextStyle, TextStyleRefinement, View, ViewContext, WeakView, WindowContext,
};
use itertools::Itertools;
use language::language_settings::ShowWhitespaceSetting;
@@ -3417,6 +3417,7 @@ impl Element for EditorElement {
line_height: Some(self.style.text.line_height),
..Default::default()
};
cx.set_view_id(self.editor.entity_id());
cx.with_text_style(Some(text_style), |cx| {
cx.with_content_mask(Some(ContentMask { bounds }), |cx| {
let mut snapshot = self.editor.update(cx, |editor, cx| editor.snapshot(cx));