From 11bcfea6d29c8fe0945b6683264230023a037d31 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 25 Apr 2024 17:04:20 +0200 Subject: [PATCH] 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 --- crates/editor/src/element.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 42b6bfb90bcd680d2cf28812fc4bf9aa98111651..14e5af444aa56f84dd0c1ccdcf5f80f0a2f2918f 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -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));