mirror of
https://github.com/storytold/gridcraft.git
synced 2026-10-30 05:37:00 -06:00
Show form notes that contain a pipe as they are
tr reads | as a context separator, so translating the Open Hyperlink note cut a URL with a pipe down to the part after it. Notes carry user data (URLs, file and sheet names); one with a pipe is now drawn verbatim. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JadgGo4G2GHaAMNb3qyygk
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
29adb19872
commit
c26290cd04
@@ -1462,7 +1462,10 @@ fn form_fields(ui: &mut egui::Ui, d: &mut Dialog) {
|
||||
}
|
||||
}
|
||||
Field::Note(t) => {
|
||||
ui.label(egui::RichText::new(lang.tr(&t)).small());
|
||||
// A note can carry user data (a URL, a file or sheet name); `tr` reads a `|` as a
|
||||
// context separator, so such a note is shown as it is.
|
||||
let text = if t.contains('|') { t.as_str() } else { lang.tr(&t) };
|
||||
ui.label(egui::RichText::new(text).small());
|
||||
}
|
||||
}
|
||||
ui.end_row();
|
||||
|
||||
@@ -39,3 +39,17 @@ fn form_fields_are_translated() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn notes_with_a_pipe_show_in_full() {
|
||||
// `tr` reads `|` as a context separator; the Open Hyperlink note carries the URL, which must
|
||||
// be shown whole so the user sees where the link really goes.
|
||||
let url = "https://example.com/report|evil.example";
|
||||
for language in ["en", "pt"] {
|
||||
let mut h = harness();
|
||||
h.state_mut().run("app.language.set", json!({"language": language})).unwrap();
|
||||
h.state_mut().open_dialog("openLink", json!({"url": url}));
|
||||
h.run_steps(3);
|
||||
assert!(h.query_by_label_contains(url).is_some(), "{language}: the link note lost part of {url}");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user