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

Add AnyQuotes support for unified quote handling similar to mini.ai nvim #22263

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

oca159
Copy link

@oca159 oca159 commented Dec 19, 2024

Edit 1:

I tested it locally and it works!

IMPORTANT:

Feedback and suggestions for improvement are greatly appreciated!

This commit introduces a new AnyQuotes text object to handle text surrounded by single quotes ('), double quotes ("), or back quotes (`) seamlessly. The following changes are included:

  • Added AnyQuotes to the Object enum to represent the new feature.
  • Registered AnyQuotes as an action in the actions! macro and register function to ensure proper integration with Vim actions like ci, ca, di, and da.
  • Extended Object::range to check for surrounding single, double, or back quotes sequentially.
  • Updated methods like is_multiline and always_expands_both_ways to ensure consistent behavior with other text objects.
  • Added support in surrounding_markers to evaluate any of the quote types when AnyQuotes is invoked.
  • This enhancement provides users with a flexible and unified way to interact with text objects enclosed by different types of quotes.

This commit introduces a new AnyQuotes text object to handle text surrounded by single quotes ('), double quotes ("), or back quotes (`) seamlessly. The following changes are included:

- Added AnyQuotes to the Object enum to represent the new feature.
- Registered AnyQuotes as an action in the actions! macro and register function to ensure proper integration with Vim actions like ci, ca, di, and da.
- Extended Object::range to check for surrounding single, double, or back quotes sequentially.
- Updated methods like is_multiline and always_expands_both_ways to ensure consistent behavior with other text objects.
- Added support in surrounding_markers to evaluate any of the quote types when AnyQuotes is invoked.
- This enhancement provides users with a flexible and unified way to interact with text objects enclosed by different types of quotes.
This commit adds comprehensive tests for the new AnyQuotes text object, ensuring proper functionality and robustness. The following tests were included:

Basic Operations: Verify ciq, caq, diq, daq, viq, and vaq commands for single quotes ('), double quotes ("), and backticks (`).
Edge Cases: Test nested quotes (e.g., ' " " '), mixed quotes, and quotes with escape characters (e.g., 'It's escaped'`).
Multiline Scenarios: Validate behavior for multiline quotes across single, double, and backtick variants.
Visual Mode: Ensure proper visual selection inside and around quotes.
These tests provide full coverage for the AnyQuotes object, ensuring it behaves consistently across various scenarios and edge cases.
Copy link

cla-bot bot commented Dec 19, 2024

We require contributors to sign our Contributor License Agreement, and we don't have @oca159 on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@maxdeviant maxdeviant changed the title feat: add AnyQuotes support for unified quote handling similar to mini.ai nvim (proposal) Add AnyQuotes support for unified quote handling similar to mini.ai nvim (proposal) Dec 19, 2024
@oca159
Copy link
Author

oca159 commented Dec 19, 2024

@cla-bot check

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Dec 19, 2024
Copy link

cla-bot bot commented Dec 19, 2024

The cla-bot has been summoned, and re-checked this pull request!

"t": "vim::Tag",
"s": "vim::Sentence",
"p": "vim::Paragraph",
"'": "vim::Quotes",
"`": "vim::BackQuotes",
"\"": "vim::DoubleQuotes",
"q": "vim::AnyQuotes",
Copy link
Author

Choose a reason for hiding this comment

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

Important code change, all the other changes in this file is just formatting

@oca159 oca159 changed the title Add AnyQuotes support for unified quote handling similar to mini.ai nvim (proposal) feat: Add AnyQuotes support for unified quote handling similar to mini.ai nvim Dec 19, 2024
@maxdeviant maxdeviant changed the title feat: Add AnyQuotes support for unified quote handling similar to mini.ai nvim Add AnyQuotes support for unified quote handling similar to mini.ai nvim Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant