fix: closing-segment markers on closed polylines; case-insensitive page-setup names

- resolve_point, set_polyline_vertex and the solver's point_for_marker
  treat the marker one past the last vertex of a closed polyline as
  vertex 0, the way line_segment already did. Equal (#1366), the axis
  pre-alignment (#1365) and the transform pin (#1361) address a picked
  segment's end that way, so on the closing segment they either refused
  the pick or pinned nothing.
- Page-setup dictionary keys compare case-insensitively: page_setup_save
  replaces "site" when "Site" exists instead of adding a second entry
  (PSETUPIN counted it as replaced, #1344), delete and rename match the
  same way, and a rename that only changes case is allowed.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Fable 5.1 committed 2026-09-20 21:12:07 +03:00
1 parent 75e7f825cd
commit a1629fd073
3 files changed
+63 -11

No files matched your search

+29 -6
View File
@@ -175,7 +175,23 @@ impl Scene {
let ObjectType::Dictionary(d) = self.document.objects.get(&dh)? else {
return None;
};
d.entries.iter().find(|(k, _)| k == name).map(|(_, h)| *h)
d.entries
.iter()
.find(|(k, _)| k.eq_ignore_ascii_case(name))
.map(|(_, h)| *h)
}
/// The dictionary's own spelling of `name` (page-setup names compare
/// case-insensitively, like every named-object dictionary key).
fn page_setup_key(&self, name: &str) -> Option<String> {
let dh = self.plotsettings_dict_handle()?;
let ObjectType::Dictionary(d) = self.document.objects.get(&dh)? else {
return None;
};
d.entries
.iter()
.find(|(k, _)| k.eq_ignore_ascii_case(name))
.map(|(k, _)| k.clone())
}
/// Create or update the named page setup from `ps` (its `page_name` and
@@ -183,7 +199,9 @@ impl Scene {
/// are inserted and registered in the dictionary.
pub fn page_setup_save(&mut self, name: &str, mut ps: PlotSettings) {
let dict_handle = self.ensure_plotsettings_dict();
ps.page_name = name.to_string();
// Replacing keeps the entry's stored spelling so the dictionary key
// and the object's page_name stay one name.
ps.page_name = self.page_setup_key(name).unwrap_or_else(|| name.to_string());
ps.owner = dict_handle;
if let Some(h) = self.page_setup_handle(name) {
ps.handle = h;
@@ -206,8 +224,12 @@ impl Scene {
let handle = if let Some(ObjectType::Dictionary(d)) =
self.document.objects.get_mut(&dict_handle)
{
let h = d.entries.iter().find(|(k, _)| k == name).map(|(_, h)| *h);
d.entries.retain(|(k, _)| k != name);
let h = d
.entries
.iter()
.find(|(k, _)| k.eq_ignore_ascii_case(name))
.map(|(_, h)| *h);
d.entries.retain(|(k, _)| !k.eq_ignore_ascii_case(name));
h
} else {
None
@@ -223,7 +245,8 @@ impl Scene {
if old == new || new.trim().is_empty() {
return;
}
if self.page_setup_handle(new).is_some() {
// A different spelling of the same name is a rename, not a collision.
if !old.eq_ignore_ascii_case(new) && self.page_setup_handle(new).is_some() {
return; // name collision
}
let Some(dict_handle) = self.plotsettings_dict_handle() else {
@@ -231,7 +254,7 @@ impl Scene {
};
let mut renamed = None;
if let Some(ObjectType::Dictionary(d)) = self.document.objects.get_mut(&dict_handle) {
if let Some(e) = d.entries.iter_mut().find(|(k, _)| k == old) {
if let Some(e) = d.entries.iter_mut().find(|(k, _)| k.eq_ignore_ascii_case(old)) {
e.0 = new.to_string();
renamed = Some(e.1);
}