Repository navigation
fix(engine): project.openText and project.fromTemplate steps require layout-legend-counts and layout-legend-subtitle - #3611
Conversation
…layout-legend-counts and layout-legend-subtitle (opengeos#3598)
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
| } | ||
| "layout.import" | "report.existingTemplate" => imported_layout_uses(id, params, &["\"subtitle\""], legend_subtitle_features), | ||
| // It opens its `text` only, whatever else the step holds. | ||
| "project.openText" => params.get("text").and_then(Value::as_str).is_some_and(text_gives_legend_subtitle), |
There was a problem hiding this comment.
Twin gap in the same family: five legend checks in this file still have no project.openText / project.fromTemplate arm, so an openText step holding a legend with any of these fields passes the older-reader check and the older reader drops the field silently:
command_uses_legend_fit(layout-legend-fit, around line 680)command_uses_legend_class_labels(layout-legend-class-labels, around line 701)command_uses_legend_order(layout-legend-order, around line 723)command_uses_legend_column_breaks(layout-legend-column-breaks, around line 740)command_uses_legend_nested_sizes(layout-legend-nested-sizes, around line 922)
This PR fixes counts, subtitle and (already) one-row and patch-size, so the same two arms are missing from those five. This PR doesn't have to fix them, but a follow-up should, with a test like the new a_saved_step_that_counts_or_subtitles_... for each. I checked the dispatch table (COMMAND_CAPABILITIES, lines 163–223) and command_uses: nothing else routes an openText step to those checks.
Category: bug
Code reviewReviewed PR #3611 ( Bugs
Security
Performance
Quality
AGENTS.md
Checked and fine
Earlier concerns skipped: 0 (no prior review threads). Change sizeCompared: the whole PR against main (merge base 7548c1b to PR head 7f0d4f4).
|
📖 Docs preview
GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the |
| /// or its notebooks. Parsed only when the text names a key, either way it is written, may hide it | ||
| /// ([`may_hide_a_key`]), or holds a step's base64 `data` ([`names_data`]). | ||
| fn text_shows_legend_counts(text: &str) -> bool { | ||
| (["show_counts", "showCounts"].iter().any(|key| text.contains(key)) || may_hide_a_key(text) || names_data(text)) |
There was a problem hiding this comment.
Low-confidence performance note, not a correctness problem. names_data is true for any text with a quoted data key, and may_hide_a_key is true for any \uXXXX escape. When either holds, every project.openText and project.fromTemplate step now gets one more full Project::from_peer_raw parse from this check. The subtitle check (text_gives_legend_subtitle) has the same shape, so a text that passes the pre-filter gets two more full parses per step. The siblings already do this, so the cost follows the existing pattern. If large saved projects with embedded data make this slow, parse once per text and share the result across the capability checks, rather than adding a parse per check.
Category: performance
Code reviewScope: one file, Bugs
Security
Performance (low confidence, inline comment posted)
Quality (release quality pass, not posted inline)
AGENTS.md (low confidence, process only)
Twins checked
Change sizeCompared with the base branch: the whole PR against main (merge base 7548c1b to PR head 7f0d4f4).
|
Pull request was closed
Summary
command_uses_legend_countsandcommand_uses_legend_subtitlehad noproject.openTextarm, unlikecommand_uses_legend_one_rowandcommand_uses_legend_patch_size, and noproject.fromTemplatearm either. A step that opened a project text holding a legend withshow_countsor asubtitlerequired neitherlayout-legend-countsnorlayout-legend-subtitle, so an older release opened it and dropped those fields without refusing.Both checks now read the opened text the way the one-row and patch-size checks do: a text reader that parses only when the text names the key (or may hide it, or holds a step's
data), then asks the project what it requires.project.fromTemplatewith inline text gets the same arm, since it opens the same text.Testing
a_saved_step_that_counts_or_subtitles_a_legend_is_found_in_text_a_project_opens;layout-legend-countsandlayout-legend-subtitleadded tothe_checks_of_an_inline_project_read_nothing_it_names(open text, no header, nested step, template, script; no raster read). Both fail without the fix, onshowCounts.checks.sh: fmt, clippy, doctests, layers and schema pass. Nextest: 8 failures, inrustgis-geolibre(runner not installed) andui-eguiline_strokes_editor_edits_one_class; all 8 fail the same way onmain.UI evidence
No visible UI change.
Related issue
Closes #3598.
Summary by CodeRabbit