forked from 1b-agent/opencadstudio-upstream
fix(snap): typed overrides yield to the prompt's options; one point-step gate
#1707 took any snap name typed at a point prompt as an override, so a prompt offering Center, Tangent, Parallel or None (ARC, ELLIPSE, CIRCLE TTR, ...) could no longer be answered with that option's name. An option the prompt offers now wins. The point-step test it copied from MTP is one helper shared by MTP and the override on both input paths. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
45bc31f730
commit
23b21b5d77
3 files changed
+38
-73
No files matched your search
@@ -50,6 +50,35 @@ impl OpenCADStudio {
|
||||
self.accepted_snaps.clear();
|
||||
}
|
||||
|
||||
/// The active command is at a point prompt (keywords allowed) and not
|
||||
/// picking an object: where MTP and typed snap overrides apply.
|
||||
pub(crate) fn point_modifier_step(&self, i: usize) -> bool {
|
||||
self.tabs[i].active_cmd.as_ref().is_some_and(|c| {
|
||||
(!c.input_kind().wants_text() || c.point_step_accepts_keywords())
|
||||
&& !c.needs_entity_pick()
|
||||
})
|
||||
}
|
||||
|
||||
/// A snap override typed at a point prompt (`MID`, `END`, `NON`, ...). An
|
||||
/// option the prompt offers wins, so `CEN` where Center is offered picks
|
||||
/// Center.
|
||||
pub(crate) fn typed_snap_override(
|
||||
&self,
|
||||
i: usize,
|
||||
token: &str,
|
||||
) -> Option<crate::snap::SnapOverrideKind> {
|
||||
let kind = crate::snap::parse_snap_override(token)?;
|
||||
if !self.point_modifier_step(i) {
|
||||
return None;
|
||||
}
|
||||
let typed = token.trim().trim_start_matches('_').to_uppercase();
|
||||
let offered = self.tabs[i].active_cmd.as_ref()?.options().iter().any(|option| {
|
||||
option.keyword.eq_ignore_ascii_case(&typed)
|
||||
|| option.label.to_uppercase().replace(' ', "").starts_with(&typed)
|
||||
});
|
||||
(!offered).then_some(kind)
|
||||
}
|
||||
|
||||
/// Apply a transparent one-shot snap override (from typed input or the context menu).
|
||||
pub(crate) fn apply_snap_override(&mut self, kind: crate::snap::SnapOverrideKind) {
|
||||
match kind {
|
||||
|
||||
Reference in new issue
Block a user