Repository navigation
Edit: duplicating during a text edit ends the edit (#2226) - #2266
bflatastic merged 1 commit into
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Update edit state after duplication crates/engine/src/cmd/edit.rs, crates/engine/src/tests/text_edit.rs |
After duplication selects the copies, the command ends text editing if the edited layer is no longer selected. The regression test checks selection, edit state, and text retention. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Low
Suggested reviewers: echelon
Merge Risk: 
Minimal · up to 60a35
-
No concrete merge-blocking defect remains identified in the reviewed change.
Architecture risk: 
Low · up to 7c0a0
-
The change affects 1 system.
Changed systems:
cratesArchitecture concerns
No architecture-level concerns identified.Review details
-
Systems and components
- observed — crates (service) was modified; 2 changed files map to changed impact.
Before / after behavior
- observed — Modified behavior in crates/engine/src/commands/edit.rs: After duplication selects the copies,
duplicatenow ends an open text edit if its layer is absent from the selected layers. - observed — Modified behavior in crates/engine/src/tests_text_edit.rs: Adds a test for duplicating a layer during text editing. It asserts that the duplicate is selected, the edit ends, and both the original and copy retain “Hello.”
-
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Title check
-
Explanation
The title "Edit: duplicating during a text edit ends the edit (
#2226)" names the main behavior change: duplicate now ends an active text edit when the edited layer is no longer selected. The raw summary and PR objectives both describe this change, and the regression test matches it. The title is specific and short, so it passes. The linked issue#2226is referenced in the title, which helps traceability. The PR comments about rebasing and CI do not affect the title assessment.
Full details: Linked Issues check
-
Explanation
[
#2226] The issue requires that a duplicate made during an in-canvas text edit must not leave the edit open on an unselected original layer. The issue allows either ending the edit when selection moves or moving the edit to the copy. At head,duplicatein crates/engine/src/cmd/edit.rs setsst.selected_layers = createdinsides.edit("Duplicate", ...). It then checkss.state.text_edit.as_ref().is_some_and(|e| !s.state.selected_layers.contains(&e.layer))and callssuper::text_edit::end_edit(s, &Value::Null). This ends the edit when the edited layer is no longer selected, which is the first option the issue allows. The regression testduplicate_during_a_text_edit_ends_the_editin crates/engine/src/tests/text_edit.rs opens a text edit withtext.edit, runsedit.duplicateon the layer, and asserts that the copy is selected,state.text_editis none, and both the original and the copy keep the text "Hello". The test covers the reported behavior. Evidence limit: the whole-PR text diff for edit.rs could not be read because changed blobs were missing from the checkout. The verdict uses the full file read at head, which shows the completeduplicatefunction, and the test diff. The PR objectives report baseline and after-change test counts and rebase/CI tasks. These are non-coding or verification notes and do not change this verdict. The previous PASS remains supported by the code at head.
Full details: Out of Scope Changes check
-
Explanation
The whole-PR changes are limited to two areas. The first is the post-edit check and
end_editcall added toduplicatein crates/engine/src/cmd/edit.rs, which implements the#2226objective. The second is the regression test added to crates/engine/src/tests/text_edit.rs, which verifies that objective. The test diff contains only the new test function and its doc comment. The raw summary reports +5/-0 for edit.rs and +14/-0 for the test file, which matches this scope. No unrelated refactoring or unrelated file changes appear in the reviewed evidence. The PR description and objectives mention rebase, lint, and CI work. Those items concern process and verification, not code outside the linked issue scope. The edit.rs diff could not be read directly, so the scope judgment for that file relies on the full file read at head and the raw summary. No unrelated change was found in the evidence available.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
|
Hi @SusieeTheLinuxUser, thanks for this PR! Most of the conflict comes from the shared module layout (#2491), which moved or split files this PR touches:
When you rebase, please also make sure it fits the other recent changes:
CI ( |
Edit > Duplicate replaces the layer selection with the copies, but an open in-canvas text edit stayed on the original layer: typing kept editing a layer that was no longer selected. When the duplicate leaves the edited layer deselected, end the edit the way storytold#2096's Deselect All does (text_edit::end_edit), in the command every caller — menu, shortcut, MCP — dispatches through. Co-Authored-By: GLM-5.3-Flash <noreply@z.ai>
7c0a022 to
60a356e
Compare
|
Merged, thank you @SusieeTheLinuxUser! It landed on |
Part of #2226
What was wrong
Edit > Duplicate(edit.duplicate) replaces the layer selection with the copies(
st.selected_layers = created), but an open in-canvas text edit (state.text_edit) keptpointing at the original layer. The canvas caret stayed on the now-unselected original: typing
after the duplicate edited the unselected layer while the copy was the selected one.
Root cause
duplicate(crates/engine/src/cmd/edit.rs) updated the selection without regard for thetext-edit state. The
deletecommand right next to it already special-cases an open text edit;duplicate did not.
What changed
After the duplicate applies, if the edited layer is no longer among the selected layers, the
command calls
text_edit::end_edit— the same close the rest of the app uses (including itsempty-created-layer cleanup), in the one place every caller (menu, shortcut, MCP, control
channel) dispatches through. This is the issue's first option, "the edit ends when the selection
moves" — the #2096 invariant for Deselect All, and After Effects' observable behaviour (the edit
commits; the copy is selected with no edit open). The alternative (moving the edit onto the copy)
was not taken.
Test
tests::text_edit::duplicate_during_a_text_edit_ends_the_edit(the crate's existing command-teststyle): a text layer with an open edit (
text.edit {layer, caret}),edit.duplicate {layers:[t]}—asserts the copy is selected,
state.text_editis none, and original and copy both carry thetext. It fails before the fix (the edit is still open on the original) and passes after.
Counts
cargo test -p effectcraft-engine: lib 745 passed / 0 failed / 5 ignored, all other binaries green;cargo clippy -p effectcraft-engine --all-targets -- -D warningsandcargo fmt --checkclean.The fix calls
text_edit::end_editdirectly, the same convention End an open text edit when Deselect All runs (#2096) #2228 introduced forDeselect All.
Written by GLM-5.3-Flash in ZCode, then reviewed with Claude Code and by me (@SusieeTheLinuxUser) before submitting.
🤖 Generated with Claude Code
Summary by CodeRabbit