From 3ec1a6c6e8e6523b232205badfc7633442ff9926 Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 29 Nov 2026 17:59:29 -0500 Subject: [PATCH 1/3] fix(ui): a picker answer that isn't opened ends its request A cancelled Add Delimited Text picker opened the dialog for a file with no name; it now opens nothing and drops the request's options. An answer held while the save prompt waits now ends the request it answered too (Add Delimited Text's options, or the command a picker was opened for), so a later, unrelated file isn't opened with them. --- crates/ui-egui/src/lib.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 6d63ec2715..8ff0162418 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -2847,6 +2847,11 @@ impl RustGisApp { }; } match name.strip_prefix(DELIMITED_PICK) { + // A cancelled picker opens nothing; its request's options end with it. + Some("") => { + self.ui.pending_csv = None; + Ok(Value::Null) + } Some(name) => match self.ui.pending_csv.take() { Some(Value::Null) => dialogs::open_csv(self, name, dialogs::CsvSource::Bytes(bytes.to_vec())), csv => self.open_bytes_with(name, bytes, csv), @@ -7712,6 +7717,13 @@ impl RustGisApp { if let Some(id) = name.strip_prefix(DXF_PICK).and_then(|p| p.split_once(':')).and_then(|(id, _)| id.parse::().ok()) { self.ui.pending_dxf.remove(&id); } + // So does the request a held answer was for: its options or command aren't left + // for a later, unrelated file to be opened with. + if name.starts_with(DELIMITED_PICK) { + self.ui.pending_csv = None; + } else if !name.starts_with('\u{1}') { + self.ui.pending_open = None; + } held += 1; continue; } @@ -10963,6 +10975,27 @@ mod peer_output_tests { assert!(notices.is_empty(), "a cancelled Shapefile picker said: {notices:?}"); assert_eq!(h.state_mut().open_picked(SHAPEFILE_PICK, &[]), Ok(Value::Null)); assert!(h.state_mut().open_picked(&format!("{SHAPEFILE_PICK}roads.shp"), &[]).is_err(), "a non-zip name is still refused"); + // A cancelled Add Delimited Text picker opens nothing and ends its request. + h.state_mut().ui.pending_csv = Some(Value::Null); + let mark = h.state().session.notice_mark(); + inbox.lock().unwrap().push((DELIMITED_PICK.to_string(), Vec::new())); + h.step(); + assert!( + h.state().ui.pending_csv.is_none() && h.state().dialogs.open.is_none(), + "a cancelled Add Delimited Text opened {:?}", + h.state().dialogs.open + ); + assert!(h.state().session.notices_since(mark).is_empty()); + // A picked file held while the prompt waits ends the picker's request: the command it + // was for isn't left for the next file opened. + h.state_mut().ui.pending_open = Some("project.fromTemplate"); + inbox.lock().unwrap().push(("other.rgistemplate".to_string(), b"{}".to_vec())); + h.step(); + assert_eq!(h.state().ui.pending_open, None); + h.state_mut().ui.pending_csv = Some(json!({"x": "lon", "y": "lat"})); + inbox.lock().unwrap().push((format!("{DELIMITED_PICK}places.csv"), b"lon,lat\n1,2\n".to_vec())); + h.step(); + assert!(h.state().ui.pending_csv.is_none(), "a held Add Delimited Text answer ends its request"); assert_eq!(h.state().session.map().layers.len(), layers, "nothing is added to the project about to be replaced"); assert_eq!(h.state().session.map().name, "Unsaved Map"); } From c70c4290773e74ce4ea360791dba15d4fa34d7e8 Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 29 Nov 2026 18:38:17 -0500 Subject: [PATCH 2/3] fix(web,mobile): a cancelled Add Delimited Text picker is answered empty The browser and phone shells answered only Import DXF and marker requests when their picker ended with nothing read, so the empty DELIMITED_PICK branch never ran there and the request's options stayed set. Both shells now answer a cancelled "text" request too. --- apps/rustgis-mobile/src/shell.rs | 9 +++++++-- apps/rustgis-web/src/web.rs | 11 ++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/apps/rustgis-mobile/src/shell.rs b/apps/rustgis-mobile/src/shell.rs index b165cc8af6..6e02572c56 100644 --- a/apps/rustgis-mobile/src/shell.rs +++ b/apps/rustgis-mobile/src/shell.rs @@ -518,9 +518,10 @@ fn remove_copy(path: &Path) { } /// Whether a request for files (`purpose`) has something waiting on its answer, which an empty -/// one ends: Import DXF (`dxf:`) or a marker's «Image…» (`marker:`). +/// one ends: Import DXF (`dxf:`), a marker's «Image…» (`marker:`) or Add Delimited +/// Text's options (`text`). fn waits(purpose: &str) -> bool { - purpose.starts_with("dxf:") || purpose.starts_with("marker:") + purpose.starts_with("dxf:") || purpose.starts_with("marker:") || purpose == "text" } /// Ends a request for files that got none (`purpose`): a dialog or marker waiting for its answer @@ -1283,5 +1284,9 @@ mod tests { answer_ended(&inbox, Some("marker:3".into())); answer_ended(&inbox, Some("data".into())); assert_eq!(*inbox.lock().unwrap(), vec![(format!("{}3:", rustgis_ui_egui::MARKER_PICK), Vec::::new())]); + // Add Delimited Text's request too, so its options don't wait for a file never coming. + let inbox = Inbox::default(); + answer_ended(&inbox, Some("text".into())); + assert_eq!(*inbox.lock().unwrap(), vec![(rustgis_ui_egui::DELIMITED_PICK.to_string(), Vec::::new())]); } } diff --git a/apps/rustgis-web/src/web.rs b/apps/rustgis-web/src/web.rs index bb6088b34a..49f92e8568 100644 --- a/apps/rustgis-web/src/web.rs +++ b/apps/rustgis-web/src/web.rs @@ -582,9 +582,14 @@ async fn read_together(mut files: Vec, mark: &str, inbox: &Inbox, }; notes.lock().unwrap_or_else(|e| e.into_inner()).push((text, true)); } - // A request something waits on (Import DXF, a marker's «Image…») with nothing read, its - // picker cancelled or its file refused or unread, is answered empty: it stops waiting. - if (mark.starts_with(rustgis_ui_egui::DXF_PICK) || mark.starts_with(rustgis_ui_egui::MARKER_PICK)) && read.is_empty() { + // A request something waits on (Import DXF, a marker's «Image…», Add Delimited Text's + // options) with nothing read, its picker cancelled or its file refused or unread, is answered + // empty: it stops waiting. + if (mark.starts_with(rustgis_ui_egui::DXF_PICK) + || mark.starts_with(rustgis_ui_egui::MARKER_PICK) + || mark == rustgis_ui_egui::DELIMITED_PICK) + && read.is_empty() + { inbox.lock().unwrap_or_else(|e| e.into_inner()).push((mark.to_string(), Vec::new())); } let (read, problems) = rustgis_ui_egui::rustgis_engine::data::io::gather_shapefiles(read); From bd718cdd80cdd1a8bc7575fcaf6531a51dc1629e Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 29 Nov 2026 19:11:02 -0500 Subject: [PATCH 3/3] Revert the shells' empty answer to a cancelled Add Delimited Text An empty DELIMITED_PICK answer clears pending_csv when it is drained, which can be after a newer text request has set its options: on the phone, a refused second picker restores the first one's options in the same frame, and the queued empty answer then wiped them. A stale pending_csv is harmless (the text picker sets it each time it opens and only its answers read it), so the shells go back to not answering. --- apps/rustgis-mobile/src/shell.rs | 9 ++------- apps/rustgis-web/src/web.rs | 11 +++-------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/apps/rustgis-mobile/src/shell.rs b/apps/rustgis-mobile/src/shell.rs index 6e02572c56..b165cc8af6 100644 --- a/apps/rustgis-mobile/src/shell.rs +++ b/apps/rustgis-mobile/src/shell.rs @@ -518,10 +518,9 @@ fn remove_copy(path: &Path) { } /// Whether a request for files (`purpose`) has something waiting on its answer, which an empty -/// one ends: Import DXF (`dxf:`), a marker's «Image…» (`marker:`) or Add Delimited -/// Text's options (`text`). +/// one ends: Import DXF (`dxf:`) or a marker's «Image…» (`marker:`). fn waits(purpose: &str) -> bool { - purpose.starts_with("dxf:") || purpose.starts_with("marker:") || purpose == "text" + purpose.starts_with("dxf:") || purpose.starts_with("marker:") } /// Ends a request for files that got none (`purpose`): a dialog or marker waiting for its answer @@ -1284,9 +1283,5 @@ mod tests { answer_ended(&inbox, Some("marker:3".into())); answer_ended(&inbox, Some("data".into())); assert_eq!(*inbox.lock().unwrap(), vec![(format!("{}3:", rustgis_ui_egui::MARKER_PICK), Vec::::new())]); - // Add Delimited Text's request too, so its options don't wait for a file never coming. - let inbox = Inbox::default(); - answer_ended(&inbox, Some("text".into())); - assert_eq!(*inbox.lock().unwrap(), vec![(rustgis_ui_egui::DELIMITED_PICK.to_string(), Vec::::new())]); } } diff --git a/apps/rustgis-web/src/web.rs b/apps/rustgis-web/src/web.rs index 49f92e8568..bb6088b34a 100644 --- a/apps/rustgis-web/src/web.rs +++ b/apps/rustgis-web/src/web.rs @@ -582,14 +582,9 @@ async fn read_together(mut files: Vec, mark: &str, inbox: &Inbox, }; notes.lock().unwrap_or_else(|e| e.into_inner()).push((text, true)); } - // A request something waits on (Import DXF, a marker's «Image…», Add Delimited Text's - // options) with nothing read, its picker cancelled or its file refused or unread, is answered - // empty: it stops waiting. - if (mark.starts_with(rustgis_ui_egui::DXF_PICK) - || mark.starts_with(rustgis_ui_egui::MARKER_PICK) - || mark == rustgis_ui_egui::DELIMITED_PICK) - && read.is_empty() - { + // A request something waits on (Import DXF, a marker's «Image…») with nothing read, its + // picker cancelled or its file refused or unread, is answered empty: it stops waiting. + if (mark.starts_with(rustgis_ui_egui::DXF_PICK) || mark.starts_with(rustgis_ui_egui::MARKER_PICK)) && read.is_empty() { inbox.lock().unwrap_or_else(|e| e.into_inner()).push((mark.to_string(), Vec::new())); } let (read, problems) = rustgis_ui_egui::rustgis_engine::data::io::gather_shapefiles(read);