Skip to content

Refactor/properties locale and paste constant#32

Merged
u8array merged 5 commits into
mainfrom
refactor/properties-locale-and-paste-constant
May 8, 2026
Merged

Refactor/properties locale and paste constant#32
u8array merged 5 commits into
mainfrom
refactor/properties-locale-and-paste-constant

Conversation

@u8array
Copy link
Copy Markdown
Owner

@u8array u8array commented May 8, 2026

No description provided.

u8array added 2 commits May 9, 2026 00:01
The literal 20 was repeated three times across duplicateObject,
duplicateSelectedObjects, and pasteObjects as the per-copy positional
offset. Name it once with a comment that explains the dots/mm relation
so future tweaks happen in one place.
PropertiesPanel rendered '{n} objects selected' and 'use arrow keys to
move' as hardcoded English in an otherwise fully-localised UI. Add two
keys (multipleSelectedFmt, multipleSelectedHint) under properties; the
former carries an {n} placeholder substituted at render time. All 32
locales filled in via add_locale_key.local.py.
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements localization for the properties panel selection text across various languages and introduces a DUPLICATE_OFFSET_DOTS constant to replace hardcoded values in the label store. Feedback suggests refining the documentation for the new constant and addressing a logic bug in duplicateSelectedObjects that results in exponential staggering of duplicated items.

Comment thread src/store/labelStore.ts Outdated
Comment thread src/store/labelStore.ts Outdated
u8array added 2 commits May 9, 2026 00:11
Gemini caught a bug surfaced by the constant extraction: the previous
'duplicateCount * DUPLICATE_OFFSET_DOTS' produced quadratic stagger
(positions 20, 60, 120, 200…) because the selection moves to each new
copy, then the next call multiplies by an ever-growing duplicateCount
on top of that already-shifted source.

The selection-follows-copy mechanic already produces linear stagger
on its own — the multiplier was unwarranted. Use a constant offset.
duplicateCount state and its selection-reset bookkeeping become dead;
remove them.

pasteObjects keeps its multiplier: the clipboard source is static, so
multiplication is the only thing producing stagger.

Add regression tests for duplicateSelectedObjects (none existed,
which is how the bug shipped). Update the constant docstring to
reflect the now-correct two-mode behaviour.
duplicateObject and duplicateSelectedObjects had near-identical bodies
after the previous fix unified them on a constant offset. Pull the
shared logic (find by id, spread + new id + offset, drop missing) into
a single helper so both actions reduce to selection-shape concerns.
@u8array
Copy link
Copy Markdown
Owner Author

u8array commented May 8, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the object duplication logic by introducing a buildOffsetCopies helper function and a DUPLICATE_OFFSET_DOTS constant, while removing the redundant duplicateCount state. It also updates the UI to support localized strings for multiple selection and adds unit tests for the new duplication behavior. A review comment suggested improving buildOffsetCopies by performing a deep clone of the props object to prevent shared state mutations and using a Map for better lookup performance.

Comment thread src/store/labelStore.ts
Two improvements from a Gemini review:

- Shallow-clone props on copy. Matches the copySelectedObjects pattern.
  Today nothing mutates props directly (updateObject builds a fresh
  object via Object.assign), so the shared reference is invisible — but
  cheap to defend now rather than wait for a future contributor's
  in-place edit to leak across copies.

- Index objs in a Map before the flatMap pass. The previous nested find
  was O(N×M); for typical labels both are tiny so it's not a real
  performance issue, but the Map form reads as 'looking things up by
  id' rather than 'scanning each time'.
@u8array u8array merged commit 2c37ac7 into main May 8, 2026
2 checks passed
@u8array u8array deleted the refactor/properties-locale-and-paste-constant branch May 9, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant