Skip to content

fix(editor): a flow insert copies only a separator a member wrote - #28

Merged
adammharris merged 1 commit into
mainfrom
agent/backlog-a-flow-insert-copies-a-separator-from-a-nested-rule
Nov 6, 2026
Merged

adammharris merged 1 commit into
mainfrom
agent/backlog-a-flow-insert-copies-a-separator-from-a-nested-rule

Conversation

@adammharris

Copy link
Copy Markdown
Member

What changed

insert_flow_map_entry and flow_map_joint in rust/fig-core/src/editor/mod.rs, for a language that sets flow_kv_sep_from_siblings:

  • A member with only space between its key and value now counts as having no separator to copy (written_kv_sep).
  • The insert copies its separator from the first member that has one, and its joint from the gap after that member.
  • With no such member, it writes what an empty mapping would (flow_map_kv_sep, or else kv_sep) and the default joint.

Why

A rule nested in a fig-css block is a selector over a flow mapping, so &:hover { b: c } has no separator after its selector and needs nothing after its }. The editor copied those bytes, wrote an entry that was not a declaration, and refused the edit with NotFound or UnsupportedOperation.

The task suggested comparing a sibling's bytes with kv_sep. This tests for non-space bytes instead, because figl's :-mode writes : , which is not its kv_sep. figl requires = or : in a flow object, so every figl member passes and its inserts take the same path as before.

Closes docs/tasks/a-flow-insert-copies-a-separator-from-a-nested-rule.md. fig-css itself takes the change at fig's next release.

How it was verified

  • ship ci: all 11 jobs passed. The TypeScript job skipped its tests locally because node_modules is missing, so that suite is left to this PR's CI.
  • bindings/rust/fig/tests/sibling_separators.rs is new and registers a small nested-rule language. Three of its four tests failed before the fix, with the task's NotFound and UnsupportedOperation, and all four pass now. The fourth is the control.
  • languages/figl/tests/edits.json gains a case for a nested object in = mode, comma-joined and JSON-embedded. figl is 155/155 with the fix. The case was not run against the unfixed editor.
  • fig-css at 601c5c2 through a scratch [patch.crates-io]: each failing set in the task returns Ok, with_declaration("&:hover{b:c}", "a", Some("blue")) returns &:hover{b:c}; a: blue, its declaration for a is blue, and its 13 tests pass.
  • fig-conformance's edit suites were not run. Only figl and fig-css set the flag, and figl's path does not change.

An insert into a non-empty flow mapping, for a format that sets
flow_kv_sep_from_siblings, took its key-value separator from the first
member and its joint from the gap after it. A rule nested in a fig-css
block has neither: `&:hover { b: c }` has a space before its value and
needs nothing after its `}`. So a declaration added to a block opening
with one was spelled without a separator, and refused as NotFound or
UnsupportedOperation.

A member whose bytes between key and value are only space now has no
separator to copy. The insert copies from the first member that has one,
and takes the joint from the gap after that member. With none, it writes
what an empty mapping would, and the default joint. figl requires `=` or
`:` in a flow object, so its inserts do not change; its edit fixtures now
hold that for a nested object.

Closes docs/tasks/a-flow-insert-copies-a-separator-from-a-nested-rule.md.

Behavioural-change: inserting into a flow mapping whose first member has only space between its key and value, in a language that sets flow_kv_sep_from_siblings, now writes a valid entry. It used to be refused with NotFound or UnsupportedOperation. fig-css's `.a { &:hover { b: c } }` takes `x` as `.a { &:hover { b: c }; x: y }`.
@adammharris
adammharris merged commit 17e31b5 into main Nov 6, 2026
10 checks passed
@adammharris
adammharris deleted the agent/backlog-a-flow-insert-copies-a-separator-from-a-nested-rule branch November 6, 2026 22:59
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