From 85e9f44bf03867213a4f88d68584543b8bd010a2 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Sat, 21 Nov 2026 08:07:55 -0600 Subject: [PATCH 1/2] editor: Let an editor show its active line only while focused Add EditorState::active_line_only_when_focused (builder) and set_active_line_only_when_focused. When set, the active line number, active-line background and the caret's fold control are hidden while neither the editor nor a popup it owns has focus. Inline-completion ghost lines keep following the caret row. Off by default. --- crates/base/src/input/base/element.rs | 117 +++++++++++++++++++++++++- crates/base/src/input/base/mode.rs | 18 ++++ crates/base/src/input/base/state.rs | 40 +++++++++ website/component/editor.md | 6 ++ website/zh-CN/component/editor.md | 2 + 5 files changed, 179 insertions(+), 4 deletions(-) diff --git a/crates/base/src/input/base/element.rs b/crates/base/src/input/base/element.rs index 698bd7b31d..8a38077fc7 100644 --- a/crates/base/src/input/base/element.rs +++ b/crates/base/src/input/base/element.rs @@ -3141,6 +3141,9 @@ pub(super) struct PrepaintState { cursor_scroll_offset: Point, /// row index (zero based), no wrap, same line as the cursor. current_row: Option, + /// The row painted as the active line: `current_row`, unless the editor + /// shows its active line only while focused and is not focused. + active_row: Option, selection_paths: Vec>, hover_highlight_path: Option>, search_match_paths: Vec<(Path, bool)>, @@ -3813,6 +3816,15 @@ impl Element for TextElement