Skip to content

Preserve line breaks when offsetting animation expressions - #3849

Open
snowyukitty wants to merge 1 commit into
JannisX11:patchfrom
snowyukitty:fix/preserve-animation-line-breaks
Open

snowyukitty wants to merge 1 commit into
JannisX11:patchfrom
snowyukitty:fix/preserve-animation-line-breaks

Conversation

@snowyukitty

Copy link
Copy Markdown

Fixes #3848.

Offset the stored Molang text rather than its export-normalized form. Keep line breaks around adjusted constants and in multi-line return expressions, and leave zero-offset axes untouched. Export normalization remains in get(). Inversion also preserves operands across CRLF/tab whitespace and handles multi-line returns.

Validation from the repository root:

  • npm run build-web
  • npm run build-electron
  • npm run generate-types

Automated Chromium checks covered position, rotation and scale expressions, LF/CRLF, leading and trailing constants, trailing semicolons, multi-statement returns, pre/post data points, repeated offsets and tiny deltas. A real gizmo drag, undo/redo and an in-memory project codec compile/load round trip retained the edited text. Additional component checks exercised global/local moves, graph dragging, graph actions and the post-value slider. Desktop execution was not tested.

To reproduce, select a position or rotation keyframe and run this in the application console:

const kf = Timeline.selected[0];
kf.set('x', '5 + math.sin(q.anim_time)\n+ math.sin(q.anim_time*50)');
kf.offset('x', 25);
console.assert(kf.data_points[0].x === '30 + math.sin(q.anim_time)\n+ math.sin(q.anim_time*50)');

The same line break should survive dragging the gizmo. The automated project round-trip check uses an in-memory codec compile/load.

This branch has not been deployed

No deployments
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