Skip to content

Follow a whole-value edit with the row that expands it - #19

Merged
ww-mw merged 2 commits into
mainfrom
value-edit-reshapes-row
Sep 9, 2026
Merged

Follow a whole-value edit with the row that expands it#19
ww-mw merged 2 commits into
mainfrom
value-edit-reshapes-row

Conversation

@ww-mw

@ww-mw ww-mw commented Sep 9, 2026

Copy link
Copy Markdown
Member

A Simulink.Parameter shows a Value row only while its value node has something to expand into. A structural edit inside that node already re-decides the row — childEdit.ts notifies the parent after every add or remove, so deleting [1 2] down to one element drops the row along with the elements.

Restating the whole value took the other route and told nobody. MatlabVariableNode.setProperty('Value', …) rebuilds the node's children from the text, which crosses the same has-children/has-none line, so retyping a matrix as a scalar cleared the elements and left the Parameter holding a childless Value row — an expander onto nothing, under a scalar — until the file was re-read.

That is invisible to a consumer that repaints by re-reading the file, which is why it has gone unnoticed, and visible to one that repaints from the node it mutated. Both .sldd editors in data-explorer-vscode are moving that way, and its cross-check of "the mutated model says what the text says" is what surfaced this.

The notification goes both ways, so the same hook brings the row back when a hidden scalar value node grows elements.

Tests

Four cases added beside the existing add/remove ones in test/parameterNode.test.ts:

  • the value row retyped as a scalar drops the row (was 1, now 0) and still serializes as 42
  • retyped as another array keeps the same node as the row
  • a hidden typed-scalar value node that grows elements gets a row
  • the entry's own value retyped as an array (the path the table takes when there is no Value row) still adds it

Full suite: 4105 passed, 26 skipped.

A Simulink.Parameter shows a Value row only while its value node has
something to expand into, and a structural edit inside that node already
re-decided the row: childEdit.ts notifies the parent after every add or
remove, so deleting [1 2] down to one element drops the row along with
the elements.

Restating the whole value took the other route and told nobody.
MatlabVariableNode.setProperty('Value', ...) rebuilds the node's children
from the text, which crosses the same has-children/has-none line — so
retyping a matrix as a scalar cleared the elements and left the Parameter
holding a childless Value row: an expander onto nothing, under a scalar,
until the file was re-read.

Invisible to a consumer that repaints by re-reading the file, which is
why it has gone unnoticed; visible to one that repaints from the node it
mutated, which is the direction both .sldd editors are moving.

The notification goes both ways, so the same hook brings the row back
when a hidden scalar value node grows elements.
@ww-mw
ww-mw merged commit cb3b451 into main Sep 9, 2026
1 check passed
@ww-mw
ww-mw deleted the value-edit-reshapes-row branch September 9, 2026 18:43
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