forked from 1b-agent/opencadstudio-upstream
fix(mtext): stop Up/Down walking command history under the editor
The MText editor paints its own caret and is not a focusable widget, so the command input keeps widget focus behind the dialog. It captures the arrow itself, which routes the key through CommandLineArrowProbe instead of ArrowKeyPressed — and that path only asked whether the command input was focused, never whether an editor was open. Up and Down therefore walked command history while the user was typing in MText. Give the probe the same rule ArrowKeyPressed already applies: while the editor is open the arrow moves its caret. The probe now carries the shift state so a held Shift still extends the selection on this path. Fixes #655
This commit is contained in:
1 parent
97a6322e2a
commit
c1c8453140
3 files changed
+27
-4
No files matched your search
+24
-2
@@ -1559,17 +1559,39 @@ impl OpenCADStudio {
|
||||
))
|
||||
}
|
||||
|
||||
Message::CommandLineArrowProbe { direction } => {
|
||||
Message::CommandLineArrowProbe {
|
||||
direction,
|
||||
extend_selection,
|
||||
} => {
|
||||
iced::widget::operation::is_focused(iced::widget::Id::new(
|
||||
crate::ui::command_line::CMD_INPUT_ID,
|
||||
))
|
||||
.map(move |focused| Message::CommandLineArrowResolved {
|
||||
direction,
|
||||
focused,
|
||||
extend_selection,
|
||||
})
|
||||
}
|
||||
|
||||
Message::CommandLineArrowResolved { direction, focused } => {
|
||||
Message::CommandLineArrowResolved {
|
||||
direction,
|
||||
focused,
|
||||
extend_selection,
|
||||
} => {
|
||||
// The MText editor paints its own caret and is not a focusable
|
||||
// widget, so the command input keeps widget focus behind the
|
||||
// dialog and captures Up / Down itself. Walking command history
|
||||
// from under an open editor is never what the key meant: while the
|
||||
// editor is up the arrow belongs to its caret, exactly as it does
|
||||
// on the ArrowKeyPressed path.
|
||||
if self.mtext_editor.is_some() {
|
||||
match direction {
|
||||
ArrowKey::Up => self.mtext_caret_move_vertical(1, extend_selection),
|
||||
ArrowKey::Down => self.mtext_caret_move_vertical(-1, extend_selection),
|
||||
ArrowKey::Left | ArrowKey::Right => {}
|
||||
}
|
||||
return Task::none();
|
||||
}
|
||||
if !focused {
|
||||
return Task::none();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user