Add a preference controlling whether selecting a colour closes the palette - #75
Merged
Merged
Conversation
Persisted boolean, defaulting to True so the existing behaviour (picking a colour accepts and closes the palette) is unchanged for everyone who never touches the setting. Non-bool and missing values fall back to the default, matching how the other prefs keys are validated.
ColorPaletteDialog gains a close_on_select argument (default True), injected by anchor.py from prefs.close_palette_on_select — the dialog stays prefs-agnostic, exactly as it already is for custom_colors. All three selection paths (swatch click, hint-mode address, and the Custom Color... picker) now funnel through _select_color(), so the flag applies consistently: with it off the colour is only highlighted and the user confirms with Enter or OK. Resolving a hint address also leaves hint mode so the selection highlight is visible once the dialog stays open. PrefsDialog exposes the setting as a checkbox next to the Custom Colors swatches.
Adds the new checkbox to the Preferences list and explains the behaviour in the Colours section, and regenerates the committed PDF with 'make pdf'. No screenshots needed regenerating: the colour palette itself is visually unchanged, and the Preferences dialog is not among the captured GUI scenarios.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The change is narrowly scoped, preserves the existing default, is consistently plumbed through call sites/UI, and is covered by targeted tests plus updated user documentation.
Pull request overview
Adds a new user preference that controls whether selecting a colour in the ColorPaletteDialog immediately accepts/closes the dialog, while preserving the current default behavior.
Changes:
- Introduces persisted
prefs.close_palette_on_select(defaultTrue) with type validation on load and persistence on save. - Refactors
ColorPaletteDialogselection handling to route all selection paths through a single_select_color()gate controlled byclose_on_select. - Wires the preference through the Preferences UI and all
anchor.pycall sites that open the palette; extends tests and updates the user guide.
File summaries
| File | Description |
|---|---|
prefs.py |
Adds close_palette_on_select preference with validated load and persisted save. |
colors.py |
Adds close_on_select arg, centralizes selection in _select_color(), leaves hint mode before selection when needed, and exposes the preference via PrefsDialog. |
anchor.py |
Passes close_on_select=prefs.close_palette_on_select to all ColorPaletteDialog constructions. |
tests/test_prefs.py |
Adds round-trip/default/corrupt/missing-key coverage for the new pref. |
tests/test_anchor_color_system.py |
Adds harness + behavioral/source-level checks ensuring the close-on-select gate is consistently applied. |
docs/user-guide.md |
Documents the new preference and updated expected palette behavior. |
Review details
- Files reviewed: 6/7 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #70
What
Adds
close_palette_on_selectto the plugin preferences, exposed in AnchorPreferences... as Selecting a color closes the color palette (next to the
Custom Colors swatches).
It defaults to
True, i.e. today's behaviour: picking a colour accepts andcloses the palette. With it off, picking only highlights the colour and the
palette stays open until the user confirms with
Enter/ OK (or discardswith
Esc) — handy when comparing a few colours, or when naming and colouringan anchor in one dialog.
How
prefs.py— new persisted boolean, validated and defaulted like the otherkeys, so old prefs files and corrupt values keep the current behaviour.
colors.py—ColorPaletteDialoggains aclose_on_select=Trueargumentrather than importing prefs itself, matching how
custom_colorsis alreadyinjected by the caller. All three selection paths — swatch click, hint-mode
address (
Tabthen e.g.a1), and the Custom Color... picker — nowfunnel through a single
_select_color()so the flag applies consistently;previously each one called
accept()on its own. Resolving a hint addressalso leaves hint mode, so the selection highlight is visible when the dialog
stays open.
anchor.py— passesclose_on_select=prefs.close_palette_on_selectat allthree places it opens the palette.
Tests
pytest tests/— 502 passing, 16 new: prefs round-trip/default/corrupt-valuehandling, both branches of the flag for swatch clicks and custom colours, and
structural checks that the hint-mode handlers and every
anchor.pycall site gothrough the shared gate.
Docs
docs/user-guide.mdupdated (Colours section + Preferences list) anddocs/anchors-user-guide.pdfregenerated withmake pdf. Screenshots were notregenerated: the colour palette is visually unchanged and the Preferences dialog
is not one of the captured GUI scenarios in
scenarios/gui.json.