Skip to content

feat(editor): Add keyboard shortcut to toggle word wrapping (resolves #60). #210

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

Merged
merged 3 commits into from
Mar 13, 2025

Conversation

Henry8192
Copy link
Collaborator

@Henry8192 Henry8192 commented Mar 12, 2025

Description

Fixes #60.
Add a keyboard shortcut Alt+Z for users to toggle word wrap.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

Open log viewer with http://localhost:3010/?filePath=https://yscope.s3.us-east-2.amazonaws.com/sample-logs/yarn-ubuntu-resourcemanager-ip-172-31-17-135.log.1.clp.zst#logEventNum=1, press Alt+Z and notice the change in line 7.

Summary by CodeRabbit

  • New Features
    • Enabled a toggle for word wrapping in the editor, allowing you to switch the wrap mode on and off.
    • Added a keyboard shortcut (Alt+Z) for quick access to the word wrap toggle.

@Henry8192 Henry8192 requested a review from a team as a code owner March 12, 2025 19:52
Copy link

coderabbitai bot commented Mar 12, 2025

Walkthrough

This pull request introduces a new function, handleWordWrapAction, to toggle the word wrap setting in the editor. It retrieves the current word wrap state and updates it accordingly. Additionally, a new action, WORD_WRAP, is added to the ACTION_NAME enum, along with a corresponding action object in the EDITOR_ACTIONS array, which includes a key binding (Alt+Z) and the label "Toggle word wrap." No changes are made to exported or public entities.

Changes

File Changes Summary
src/components/Editor/index.tsx Added handleWordWrapAction function to toggle the editor’s wordWrap setting and modified handleEditorCustomAction to include a case for ACTION_NAME.WORD_WRAP.
src/utils/actions.ts Introduced WORD_WRAP value in ACTION_NAME enum and added an action object with key binding Alt+Z and label "Toggle word wrap" to EDITOR_ACTIONS array.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant EditorComponent
    participant EditorInstance

    User->>EditorComponent: Trigger WORD_WRAP action (Alt+Z)
    EditorComponent->>EditorInstance: Get current wordWrap setting
    EditorInstance-->>EditorComponent: Return current wordWrap ("on"/"off")
    EditorComponent->>EditorInstance: Update options with toggled wordWrap
Loading

Possibly related PRs

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e906ed1 and e0a72b7.

📒 Files selected for processing (2)
  • src/components/Editor/index.tsx (2 hunks)
  • src/utils/actions.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/utils/actions.ts
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}`: - Prefer `false == ...

**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}: - Prefer false == <expression> rather than !<expression>.

  • src/components/Editor/index.tsx
🔇 Additional comments (2)
src/components/Editor/index.tsx (2)

115-127: Implementation looks good!

The function properly toggles the word wrap setting between "on" and "off" by retrieving the current setting and updating it accordingly. The JSDoc comment clearly describes the function's purpose, addressing the previous lint warning.

I appreciate the use of "on" === currentWordWrap instead of currentWordWrap === "on", which follows the coding guideline of preferring false == <expression> rather than !<expression>.


173-175: LGTM! Clean implementation of the new action handler.

The new case for ACTION_NAME.WORD_WRAP is properly implemented, and it correctly calls the handleWordWrapAction function. The structure follows the same pattern as other action handlers in the switch statement.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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

@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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c64c8cb and e906ed1.

📒 Files selected for processing (1)
  • src/components/Editor/index.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}`: - Prefer `false == ...

**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}: - Prefer false == <expression> rather than !<expression>.

  • src/components/Editor/index.tsx
🪛 GitHub Check: lint-check
src/components/Editor/index.tsx

[failure] 115-115:
Missing JSDoc block description

🪛 GitHub Actions: lint
src/components/Editor/index.tsx

[error] 115-115: ESLint found too many warnings (maximum: 0). Warning: Missing JSDoc block description (jsdoc/require-description).

🔇 Additional comments (2)
src/components/Editor/index.tsx (2)

119-126: Implementation looks good

The word wrap toggle implementation is clean and follows the project's coding guidelines. The ternary operator correctly uses "on" === currentWordWrap pattern rather than negation.


172-174: Action handler implementation is correct

The integration with the editor's action handling system is properly implemented, matching the pattern of other action handlers.

@Henry8192 Henry8192 requested a review from junhaoliao March 12, 2025 20:55
Copy link
Member

@junhaoliao junhaoliao left a comment

Choose a reason for hiding this comment

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

For the PR title, how about

feat(editor): Add keyboard shortcut to toggle word wrapping (resolves #60).

@Henry8192 Henry8192 changed the title fix(editor): Add keyboard shortcut to toggle word wrapping (fixes #60). feat(editor): Add keyboard shortcut to toggle word wrapping (resolves #60). Mar 13, 2025
@Henry8192 Henry8192 merged commit 96e6436 into y-scope:main Mar 13, 2025
4 checks passed
@Henry8192 Henry8192 deleted the wordwrap-shortcut branch March 13, 2025 18:06
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.

new-log-viewer: Add keyboard shortcut to toggle word wrapping.
2 participants