text: the editor's I-beam request in its own function (cognitive complexity)

This commit is contained in:
aiongg
2026-11-22 05:55:54 +00:00
parent e49f8de1ea
commit d40340cd42
+9 -5
View File
@@ -445,6 +445,14 @@ fn char_at(lines: &[HostLine], pos: TextPos) -> usize {
line.chars.start + line.text[..byte].chars().count()
}
/// The I-beam is the editor's over its text and while its own press is held; elsewhere the canvas's tool or the rest
/// of the UI sets the pointer.
fn show_i_beam(cx: &mut Cx<'_, TextEditor<'_>>, phase: &PressPhase, vertical: bool) {
if !matches!(phase, PressPhase::Idle) {
cx.cursor(if vertical { CursorIcon::VerticalText } else { CursorIcon::Text }, CursorPriority::Hover);
}
}
/// The clipboard's text when the pass's input asks to paste and the clipboard has it ready.
fn pasted_text(cx: &mut Cx<'_, TextEditor<'_>>, inputs: &[EditorInput]) -> Option<std::sync::Arc<str>> {
if !inputs.iter().any(|input| matches!(input, EditorInput::Edit(EditCommand::Paste))) {
@@ -620,11 +628,7 @@ impl Component for TextEditor<'_> {
if let Some(text) = copied {
cx.clipboard().put(&[ClipItem::Text(text.into())]);
}
// The I-beam is the editor's over its text and while its own press is held; elsewhere the canvas's tool or the
// rest of the UI sets the pointer.
if !matches!(press.phase, PressPhase::Idle) {
cx.cursor(if vertical { CursorIcon::VerticalText } else { CursorIcon::Text }, CursorPriority::Hover);
}
show_i_beam(cx, &press.phase, vertical);
if done.changed {
cx.propose(selection);
} else if selection != before {