Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix code transform animation #4111

Closed

Conversation

Mindev27
Copy link

Closed #4103

I added a new CodeTransform function. The current Transform with Code looked weird, but now it works much better.

The logic is as follows:

When applying CodeTransform from before_code to after_code:

  • Split both before_code and after_code into lines and remove leading indentation.
  • Use a brute-force algorithm to match exactly the same lines. (This naive approach has a time complexity of O(N²), but since the typical code length is not very long, I believe it works fine in practice.)
  • If a line in before_code does not match, it will be removed with a FadeOut animation. If a line in after_code does not match, it will be added with a FadeIn animation. This transition is visually presented through animation.

This is my first PR! Any advice or suggestions will be appreciated :)

Below are videos demonstrating the difference before and after applying the CodeTransform.

Using Transform (Before)

CodeAnimation.mp4

Using CodeTransform (After)

CodeAnimation.mp4

Reviewer Checklist

  • The PR title is descriptive enough for the changelog, and the PR is labeled correctly
  • If applicable: newly added non-private functions and classes have a docstring including a short summary and a PARAMETERS section
  • If applicable: newly added functions and classes are tested

@Mindev27 Mindev27 closed this Jan 18, 2025
@Mindev27 Mindev27 deleted the fix/code-transform-animation branch January 18, 2025 04:33
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.

Code Transform Animation applies to the entire code instead of the changed lines
1 participant