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

Support collapseUnchanged option in CodeMirror's merge view #2129

Merged
merged 4 commits into from
Aug 22, 2024

Conversation

VasylMarchuk
Copy link
Collaborator

@VasylMarchuk VasylMarchuk commented Aug 21, 2024

Related to #1231

Brief

This adds support for collapsing long blocks of unchanged lines in CodeMirror's merge view.

Details

  • Added @collapseUnchanged argument to CodeMirror component
  • Added a test for @collapseUnchanged argument
  • Fixed styles of .cm-deletedChunk
  • There is currently no straightforward way to customize "⦚ X unchanged lines ⦚" text :(

Video

2024-08-22.11.41.58.mov

Checklist

  • I've thoroughly self-reviewed my changes
  • I've added tests for my changes, unless they affect admin-only areas (or are otherwise not worth testing)
  • I've verified any visual changes using Percy (add a commit with [percy] in the message to trigger)

Summary by CodeRabbit

  • New Features

    • Introduced a new option to collapse unchanged lines within the CodeMirror editor.
    • Added a checkbox in the UI to enable or disable the collapsing functionality.
  • Bug Fixes

    • Improved handling of document states for better user experience.
  • Visual Improvements

    • Enhanced styling for visual consistency of deleted code segments in the editor.
  • Tests

    • Added integration tests to verify functionality related to the new collapsing feature.

Copy link

codecov bot commented Aug 21, 2024

Bundle Report

Changes will decrease total bundle size by 182.21kB ⬇️

Bundle name Size Change
client-array-push 35.36MB 182.21kB ⬇️

Copy link

Test Results

  1 files  ±0    1 suites  ±0   6m 4s ⏱️ - 1m 19s
566 tests +2  530 ✅ +1  36 💤 +1  0 ❌ ±0 
581 runs  +2  545 ✅ +1  36 💤 +1  0 ❌ ±0 

Results for commit a276f12. ± Comparison against base commit a005c8e.

Copy link

codecov bot commented Aug 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Additional details and impacted files

📢 Thoughts on this report? Let us know!

@VasylMarchuk VasylMarchuk marked this pull request as ready for review August 22, 2024 08:54
Copy link
Contributor

coderabbitai bot commented Aug 22, 2024

Walkthrough

The updates introduce a new feature for the CodeMirror component, allowing users to collapse unchanged lines in the document. Changes were made to various files, including the component's template, TypeScript definitions, controller, styles, and tests, to accommodate this functionality, ensuring proper integration and behavior while enhancing document management capabilities.

Changes

File Change Summary
app/components/code-mirror.{hbs,ts} Modified did-update bindings to include @collapseUnchanged. Updated method names and interface signatures to support the new feature.
app/controllers/demo/code-mirror.ts Added and initialized originalDocument and collapseUnchanged properties. Updated sample document data.
app/utils/code-mirror-themes.ts Introduced a new style for .cm-deletedChunk to improve visual consistency in the editor.
tests/integration/components/code-mirror-test.js Added tests for the collapseUnchanged feature, verifying component behavior when toggling this property.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CodeMirror Component
    User->>CodeMirror Component: Toggle collapseUnchanged
    CodeMirror Component->>Document Renderer: Update display based on collapseUnchanged
    Document Renderer-->>CodeMirror Component: Render updated view
    CodeMirror Component-->>User: Display updated editor state
Loading

Poem

🐇 In the code where changes sprout,
A new feature brings about,
Lines that stay the same, they fold,
In the editor, a sight to behold!
With checks and styles, all aligned,
A joyful leap, a leap refined! 🐰


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a005c8e and a276f12.

Files selected for processing (6)
  • app/components/code-mirror.hbs (1 hunks)
  • app/components/code-mirror.ts (4 hunks)
  • app/controllers/demo/code-mirror.ts (2 hunks)
  • app/templates/demo/code-mirror.hbs (2 hunks)
  • app/utils/code-mirror-themes.ts (1 hunks)
  • tests/integration/components/code-mirror-test.js (1 hunks)
Additional comments not posted (10)
app/utils/code-mirror-themes.ts (1)

34-37: Consistent styling for .cm-deletedChunk.

The addition of the .cm-deletedChunk style ensures visual consistency with other elements by matching line height and padding.

app/components/code-mirror.hbs (1)

27-29: Enhanced functionality with @collapseUnchanged.

The addition of @collapseUnchanged allows the component to handle the collapse of unchanged lines, enhancing document management capabilities.

app/controllers/demo/code-mirror.ts (2)

49-52: Expanded sample data for documents.

The extensive set of example documents enhances testing and demonstration capabilities.


179-179: New collapseUnchanged property.

The collapseUnchanged property enhances the controller's functionality by controlling the visibility of unchanged document sections.

app/templates/demo/code-mirror.hbs (2)

135-138: Addition of collapseUnchanged checkbox looks good.

The new checkbox for enabling the collapseUnchanged feature is well-integrated into the existing UI. The conditional disabling based on originalDocument is appropriate.


291-291: Ensure correct binding of collapseUnchanged attribute.

The @collapseUnchanged attribute is correctly added to the CodeMirror component. Verify that this attribute is correctly handled in the component logic.

app/components/code-mirror.ts (3)

180-183: New collapseUnchanged property is well-documented.

The addition of the collapseUnchanged property to the Signature interface is clear and well-documented. This enhances the component's functionality.


242-245: Method renaming reflects expanded functionality.

The method originalDocumentOrMergeControlsOrCollapseUnchanged accurately reflects the expanded functionality. Ensure that all references to the old method name are updated.


308-314: Verify unifiedMergeView logic for collapseUnchanged.

The logic for setting collapseUnchanged in unifiedMergeView is clear. Verify that the options { margin: 2, minSize: 4 } meet the feature's requirements.

tests/integration/components/code-mirror-test.js (1)

377-387: Basic test coverage for collapseUnchanged is added.

The test ensures the editor does not break when collapseUnchanged is toggled. Consider expanding the test to validate the actual collapsing behavior.

@VasylMarchuk VasylMarchuk merged commit 69ae5b8 into main Aug 22, 2024
6 of 7 checks passed
@VasylMarchuk VasylMarchuk deleted the codemirror-merge-collapse-unchanged branch August 22, 2024 09:16
@coderabbitai coderabbitai bot mentioned this pull request Nov 20, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants