Refactor: extract recent-color MRU logic into RecentColors helper#5
Merged
Merged
Conversation
The de-dup/insert/cap-at-8 sequence for the editor's recent-color swatches lived inline in EditorView. Hoist it into a pure RecentColors.recording(_:into:limit:) function (behavior-preserving) and have the view delegate to it. Adds RecentColorsTests (6 cases).
GamalAnwar
added a commit
that referenced
this pull request
Jun 18, 2026
Hoist the editor's recent-color de-dup/insert/cap-at-8 rule out of EditorView into a pure RecentColors.recording(_:into:limit:). Adds RecentColorsTests (6 cases). Behavior-preserving.
GamalAnwar
added a commit
that referenced
this pull request
Jun 18, 2026
Hoist the editor's recent-color de-dup/insert/cap-at-8 rule out of EditorView into a pure RecentColors.recording(_:into:limit:). Adds RecentColorsTests (6 cases). Behavior-preserving.
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.
Summary
Fourth SOLID-refactor slice (behavior-preserving): pull the recent-color list rule out of
EditorView.The de-dup / insert-at-front / cap-at-8 sequence for the editor's recent-color swatches was inline in the view. Extracted into a pure
RecentColors.recording(_:into:limit:)function; the view now delegates to it. Trims a piece of theEditorViewgod object and makes the rule unit-testable.Tests
RecentColorsTests(6 cases): insert into empty, new-to-front, existing-moves-to-front (no dup), cap dropping oldest, recording-at-capacity keeps count, custom limit.🤖 Generated with Claude Code
Generated by Claude Code