Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions crates/ui-egui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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("") => {
Comment thread
giswqs marked this conversation as resolved.
Resolved
self.ui.pending_csv = None;
Ok(Value::Null)
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
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),
Expand Down Expand Up @@ -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::<u64>().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) {
Comment thread
giswqs marked this conversation as resolved.
Resolved
self.ui.pending_csv = None;
} else if !name.starts_with('\u{1}') {
self.ui.pending_open = None;
}
held += 1;
continue;
}
Expand Down Expand Up @@ -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");
Comment thread
giswqs marked this conversation as resolved.
Resolved
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");
}
Expand Down
Loading