forked from 1b-agent/opencadstudio-upstream
fix(command_line): preserve argument casing
This commit is contained in:
1 parent
43bdd18061
commit
ddbfb8f72b
4 files changed
+40
-16
No files matched your search
@@ -369,10 +369,15 @@ impl OpenCADStudio {
|
||||
self.command_line.input.push_str(&s);
|
||||
}
|
||||
} else {
|
||||
// Command-line entry is shown uppercase — except in
|
||||
// free-form text prompts, where the typed case is the
|
||||
// content (matches the CommandInput route).
|
||||
if self.is_free_text_active() {
|
||||
// Preserve case while entering a command or literal/free-text
|
||||
// value. Active single-token prompt keywords keep their
|
||||
// established uppercase normalization.
|
||||
let preserve_case = self.tabs[i].active_cmd.is_none()
|
||||
|| self.is_free_text_active()
|
||||
|| self.command_line.literal_spaces
|
||||
|| self.command_line.input.starts_with('>')
|
||||
|| s.starts_with('>');
|
||||
if preserve_case {
|
||||
self.command_line.input.push_str(&s);
|
||||
} else {
|
||||
self.command_line.input.push_str(&s.to_uppercase());
|
||||
|
||||
+19
-11
@@ -2796,16 +2796,16 @@ impl OpenCADStudio {
|
||||
// string, a path, `UCS Z 90` as one line) can be typed; the `>`
|
||||
// is stripped on submit. (Unfocused Space repeats the last
|
||||
// command via CommandSpace.)
|
||||
// Command-line entry is shown uppercase — except while the
|
||||
// active command collects free-form text (cell text, TEXT /
|
||||
// MTEXT bodies), where the typed case is the content and
|
||||
// Space must stay in the buffer.
|
||||
// Preserve command-entry input exactly. Active single-token
|
||||
// prompt keywords keep their established uppercase behavior;
|
||||
// `CommandLine::submit` uppercases only the command verb.
|
||||
let text_with_spaces = self.is_free_text_active();
|
||||
let active_prompt = self.tabs[self.active_tab].active_cmd.is_some();
|
||||
let literal = self.command_line.literal_spaces || s.starts_with('>');
|
||||
let s = if text_with_spaces || literal {
|
||||
s
|
||||
} else {
|
||||
let s = if active_prompt && !text_with_spaces && !literal {
|
||||
s.to_uppercase()
|
||||
} else {
|
||||
s
|
||||
};
|
||||
// A space submits (acts like Enter). The whole value is handed to
|
||||
// the submit path, which tokenises multi-token lines — so a typed
|
||||
@@ -12849,13 +12849,13 @@ mod free_text_entry_tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn normal_commands_still_uppercase_and_submit_on_space() {
|
||||
fn command_input_preserves_case_and_submits_multi_token_lines() {
|
||||
let mut app = OpenCADStudio::new_for_test();
|
||||
app.automation_op(r#"{"op":"new"}"#);
|
||||
// No free-text command active: entry is uppercased…
|
||||
// Ordinary command entry now retains its typed case…
|
||||
let _ = app.update(Message::CommandInput("lin".into()));
|
||||
assert_eq!(app.command_line.input, "LIN");
|
||||
// …and a pasted multi-token line runs as a command, not as text.
|
||||
assert_eq!(app.command_line.input, "lin");
|
||||
// …and a pasted multi-token line still submits as a command.
|
||||
let _ = app.update(Message::CommandInput("LINE 0,0 10,10".into()));
|
||||
assert!(
|
||||
app.command_line.input.is_empty(),
|
||||
@@ -12864,6 +12864,14 @@ mod free_text_entry_tests {
|
||||
assert_eq!(app.text_entry_mode(), TextEntryMode::Command);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn typed_command_characters_preserve_case() {
|
||||
let mut app = OpenCADStudio::new_for_test();
|
||||
app.automation_op(r#"{"op":"new"}"#);
|
||||
let _ = app.update(Message::CommandAppendChar("MyPath".into()));
|
||||
assert_eq!(app.command_line.input, "MyPath");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn literal_command_input_preserves_case() {
|
||||
let mut app = OpenCADStudio::new_for_test();
|
||||
|
||||
@@ -1450,6 +1450,7 @@ mod ds_set_handle_tests {
|
||||
.get(&old_name)
|
||||
.unwrap()
|
||||
.clone();
|
||||
style.dimdle = 7.0;
|
||||
let before = style.dimdle;
|
||||
app.tabs[i].scene.document.dim_styles.remove(&old_name);
|
||||
style.name = "ARCH|Imported".to_string();
|
||||
@@ -1459,7 +1460,7 @@ mod ds_set_handle_tests {
|
||||
assert!(app.selected_dimstyle_is_read_only());
|
||||
app.ds_dimdle = "456".to_string();
|
||||
app.apply_dimstyle_bufs(i);
|
||||
assert_ne!(
|
||||
assert_eq!(
|
||||
app.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
|
||||
@@ -1429,6 +1429,16 @@ mod tests {
|
||||
assert!(m.iter().any(|c| c == "LINE"), "got {m:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn submit_uppercases_only_the_command_verb() {
|
||||
let mut line = CommandLine::new();
|
||||
line.input = "open /home/u/My.dwg --PluginArg".to_string();
|
||||
assert_eq!(
|
||||
line.submit().as_deref(),
|
||||
Some("OPEN /home/u/My.dwg --PluginArg")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn aliases_are_hidden_but_their_command_survives() {
|
||||
// The alias `L` is dropped from suggestions while `LINE` (its target)
|
||||
|
||||
Reference in new issue
Block a user