Skip to content

Character and Paragraph Styles: a new style's name is trimmed as a rename trims it - #2726

Merged
bflatastic merged 2 commits into
storytold:mainfrom
dotCooCoo:fix/style-names-trimmed-on-create
Oct 17, 2026
Merged

bflatastic merged 2 commits into
storytold:mainfrom
dotCooCoo:fix/style-names-trimmed-on-create

Conversation

@dotCooCoo

Copy link
Copy Markdown
Contributor

What and why

charStyle.new and paraStyle.new kept the name they were given as it was, while charStyle.rename and paraStyle.rename trim the white space around the new name. So charStyle.new {name: " Body"} made a style " Body" beside "Body", and a blank name was refused with the message for a name that is taken. The reference app's Character Styles and Paragraph Styles panels make a style with Create New Style (Character and paragraph styles). The page does not say what happens to white space around a name, so this change uses the rule of VectorCraft's renames.

  • charStyle.new and paraStyle.new trim the name as rename does (crates/engine/src/cmd/textstyles.rs:553), compare the trimmed name with the styles there are, and refuse a name that is then empty with rename's message, "`` is empty or already used". charStyle.duplicate and `paraStyle.duplicate` name the copy from the trimmed name.
  • symbol.new and symbol.duplicate had the same fault: symbol.options trims newName (crates/engine/src/cmd/brushsym.rs:701), and they now trim the name in the same way. A blank name gives "New Symbol" as before, and a blank newName gives " copy" instead of a symbol named with the blank.
  • library.use adds a library's text style under its trimmed name, so a library file whose style is named " Body " still applies.
  • docs/mcp.md describes the trimming in the symbols bullet and the Libraries paragraph, and docs/target-app-parity.md has one line for it. The change adds no message or label, so the catalogs do not change.

A script that makes a style or symbol with white space around its name now gets the name without it.

How it was tested

New tests, each failing on main:

  • cmd::textstyles::tests::new_styles_trim_their_names_as_a_rename_does (vectorcraft-engine): both kinds of style, the duplicate check on the trimmed name, a blank name, and Duplicate of a style whose saved name has spaces around it
  • tests_brushsym::new_and_duplicate_symbols_trim_their_names_as_a_rename_does (vectorcraft-engine): New Symbol and Duplicate Symbol with spaced and blank names
  • tests_library::a_library_style_named_with_spaces_comes_in_trimmed (vectorcraft-engine): an imported library's spaced character and paragraph styles applied with library.use

Targeted checks on the final tree: cargo clippy -p vectorcraft-engine --all-targets -- -D warnings; the new tests and the other tests in textstyles, tests_brushsym, tests_library and params; cargo fmt --all -- --check; cargo xtask brands, layers and assets.

On Windows 11 (x86-64) with rustc 1.99.1, on top of main at f5511df:

  • CRAFT_FONTS_DIR=<craft-fonts checkout> cargo xtask ci passes its 10 steps: 7,853 tests passed, 0 failed, 11 ignored.

git merge-tree reports no conflicts with main at f5511df or at f7de3d6; merged with f7de3d6, the style, symbol and library tests pass. #1942 already conflicts with main in brushsym.rs. With this branch, its symbol_new hunk also takes in the name line; the resolution keeps this branch's trimmed name line and #1942's dynamic line.

Checklist

  • cargo xtask ci passes (fmt, clippy, tests, assets, brands, layers, wasm).
  • No panics in shipped code: no unwrap(), expect(), panic!, unreachable!, todo! or
    unimplemented! outside tests, and no unchecked indexing on data from files, parameters or
    messages. Errors are returned as Result and shown to the user
    (why and how).
  • Clean-room: nothing copied from Adobe products or GPL/AGPL code (AGENTS.md).
  • Every new asset has a row in ASSETS.md.

dotCooCoo and others added 2 commits October 18, 2026 01:32
…name trims it

charStyle.new and paraStyle.new kept the name they were given as it
was, while charStyle.rename and paraStyle.rename trim the white space
around the new name. So a script could make a style " Body" beside
"Body", and a blank name was refused with the message for a name that
is taken.

New Character Style and New Paragraph Style now trim the name as rename
does, compare the trimmed name with the styles there are, and refuse a
name that is then empty with rename's message. Duplicate names the copy
from the trimmed name. symbol.new and symbol.duplicate trim the name as
symbol.options trims newName, and a blank newName gives "<name> copy"
instead of a symbol named with the blank. library.use adds a library's
text style under its trimmed name, so a library file whose style is
named with spaces around it still applies.

Docs: docs/mcp.md, docs/target-app-parity.md.
@bflatastic
bflatastic force-pushed the fix/style-names-trimmed-on-create branch from 5f9388b to f5d61f6 Compare October 17, 2026 18:56
@bflatastic
bflatastic merged commit f4668bf into storytold:main Oct 17, 2026
2 of 3 checks passed
@bflatastic

Copy link
Copy Markdown
Member

Thanks @dotCooCoo, merged. One commit on top: a blank new style name now says "give the style a name" instead of the empty-name/already-used message. It went through the full gate (fmt, clippy, tests, layers, wasm) in today's batch.

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.

2 participants