mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-18 07:49:26 +00:00
Merge pull request #7543 from dotCooCoo/fix/dialogs-keep-preview-warning
Type: typing kept when a dialog or a panel previews keeps its warning and selection
This commit is contained in:
@@ -146,6 +146,31 @@ fn type_tool_inserts_at_its_caret_and_deletes_the_graphic_whole() {
|
||||
assert_eq!(inline_count(&obj(&s, id)), 1);
|
||||
}
|
||||
|
||||
/// With Performance › Real-time Drawing and Editing off, the typing waits for its session to end:
|
||||
/// a graphic inserted while typing applies it first, as a step of its own, and goes in at the
|
||||
/// caret after it.
|
||||
#[test]
|
||||
fn inserting_while_deferred_typing_keeps_the_typing() {
|
||||
let mut s = session();
|
||||
s.prefs.real_time_drawing = false;
|
||||
// The new type starts empty: the caret after "Pay " is past the end of the text until the
|
||||
// typing is applied.
|
||||
s.prefs.placeholder_text = false;
|
||||
circle_symbol(&mut s, "Mana", 10.0);
|
||||
s.execute("symbol.setCurrent", &json!({"name": "Mana"})).unwrap();
|
||||
let v = ViewInfo::default();
|
||||
s.select_tool("type", v).unwrap();
|
||||
for k in [PointerKind::Down, PointerKind::Up] {
|
||||
s.pointer(&PointerEvent::new(k, 50.0, 300.0), v).unwrap();
|
||||
}
|
||||
let id = s.doc().unwrap().selection.objects[0];
|
||||
s.tool_text("Pay ", v).unwrap();
|
||||
s.execute("text.insertInline", &json!({})).unwrap();
|
||||
assert_eq!(obj(&s, id).plain_text(), format!("Pay {INLINE_CHAR}"));
|
||||
let labels: Vec<String> = s.doc().unwrap().history.undo.iter().map(|e| e.label.clone()).collect();
|
||||
assert_eq!(labels[labels.len() - 2..], ["Typing", "Insert Inline Symbol"], "{labels:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn inline_graphics_follow_their_symbol() {
|
||||
let mut s = session();
|
||||
|
||||
@@ -2606,6 +2606,35 @@ fn settling_typing_for_a_tool_shows_its_preview_warning() {
|
||||
s.pointer(&PointerEvent::new(PointerKind::Up, 50.0, 380.0).with_mods(cmd), ViewInfo::default()).unwrap();
|
||||
}
|
||||
|
||||
/// Typing kept as its own step when a dialog or a panel begins its preview, or when the font menus
|
||||
/// end the typing session, returns its applied preview's warning for the status bar. A preview
|
||||
/// without a warning returns none, and with no typing in progress nothing is kept and no step is
|
||||
/// added.
|
||||
#[test]
|
||||
fn settling_typing_for_a_dialog_returns_its_preview_warning() {
|
||||
let warned = |w: &[String]| w.iter().any(|m| m.contains("type"));
|
||||
let steps = |s: &Session| s.doc().unwrap().history.undo.len();
|
||||
let mut s = deferred_bloat("Typing", true, "selection");
|
||||
let before = steps(&s);
|
||||
let w = s.begin_interaction_warned("Offset Path").unwrap();
|
||||
assert!(warned(&w), "{w:?}");
|
||||
assert_eq!(steps(&s), before + 1, "the typing is a step of its own");
|
||||
assert_eq!(s.doc().unwrap().interaction.as_ref().map(|it| it.label.as_str()), Some("Offset Path"));
|
||||
|
||||
let mut s = deferred_bloat("Typing", true, "selection");
|
||||
let w = s.keep_typing().unwrap();
|
||||
assert!(warned(&w), "{w:?}");
|
||||
assert!(!s.in_interaction());
|
||||
assert_eq!(steps(&s), before + 1);
|
||||
let w = s.keep_typing().unwrap();
|
||||
assert!(w.is_empty(), "{w:?}");
|
||||
assert_eq!(steps(&s), before + 1, "nothing in progress adds no step");
|
||||
|
||||
let mut s = deferred_bloat("Typing", false, "selection");
|
||||
let w = s.begin_interaction_warned("Offset Path").unwrap();
|
||||
assert!(w.is_empty(), "{w:?}");
|
||||
}
|
||||
|
||||
/// File Handling › Use Low Resolution Proxy for Linked EPS (#394): off by default; toggling it does
|
||||
/// not replace full-resolution pixels already in the document.
|
||||
#[test]
|
||||
|
||||
@@ -3173,6 +3173,41 @@ fn a_previewed_transform_while_typing_keeps_the_typing() {
|
||||
assert!((left(&s, id) - 400.0).abs() < 1e-6);
|
||||
}
|
||||
|
||||
/// With Performance › Real-time Drawing and Editing off, the typing is applied when its session
|
||||
/// ends. Ending it for another edit applies it first, as a step of its own: a dialog or a panel
|
||||
/// beginning its preview, the font menus ([`Session::keep_typing`]), a paint for the selected
|
||||
/// characters.
|
||||
#[test]
|
||||
fn ending_deferred_typing_for_another_edit_keeps_the_typing() {
|
||||
let typed = |end: &dyn Fn(&mut Session)| {
|
||||
let mut s = session();
|
||||
s.prefs.real_time_drawing = false;
|
||||
let v = ViewInfo::default();
|
||||
let id = text(&mut s, "Hello");
|
||||
s.select_tool("type", v).unwrap();
|
||||
let b = s.doc().unwrap().doc.bounds_of(&[id], false).unwrap();
|
||||
click(&mut s, b.x1 - 1.0, b.center().y);
|
||||
s.tool_text(" world", v).unwrap();
|
||||
assert_eq!(obj(&s, id).plain_text(), "Hello", "the typing waits for its session to end");
|
||||
let steps = undo_labels(&s).len();
|
||||
end(&mut s);
|
||||
assert_eq!(obj(&s, id).plain_text(), "Hello world");
|
||||
assert_eq!(undo_labels(&s)[steps], "Typing", "{:?}", undo_labels(&s));
|
||||
};
|
||||
typed(&|s| {
|
||||
assert!(s.begin_interaction_warned("Fill Color").unwrap().is_empty());
|
||||
s.preview("paint.setFill", &json!({"color": "#00a000"})).unwrap();
|
||||
s.commit_interaction().unwrap();
|
||||
});
|
||||
typed(&|s| {
|
||||
assert!(s.keep_typing().unwrap().is_empty());
|
||||
assert!(!s.in_interaction());
|
||||
});
|
||||
typed(&|s| {
|
||||
s.execute("paint.setFill", &json!({"color": "#00a000"})).unwrap();
|
||||
});
|
||||
}
|
||||
|
||||
/// #1950: a colour previewed while typing (the Color Picker, a Color panel slider) colours the
|
||||
/// typed text: its interaction used to join the typing session and preview from the document
|
||||
/// before the typing, so the new type came back as its placeholder text.
|
||||
|
||||
Reference in New Issue
Block a user