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

The CommentaryTextObject in commentary no longer contains spaces. #1097

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

CCCC-L
Copy link

@CCCC-L CCCC-L commented Feb 11, 2025

CommentaryTextObject no longer contains spaces to be consistent with neovim

@AlexPl292
Copy link
Member

Hi, thank you for your contribution! Can you please add some tests for your case in CommentaryExtensionTest?
Also, take a look at the TeamCity failed build, as it contains some failed tests from this class.

@CCCC-L
Copy link
Author

CCCC-L commented Feb 23, 2025

Hi, thank you for your contribution! Can you please add some tests for your case in CommentaryExtensionTest? Also, take a look at the TeamCity failed build, as it contains some failed tests from this class.

Since blank lines are no longer regarded as comments, the following several test methods cannot pass. Can I modify the contents of both "Expected" and "Actual"?

test text object deletes single line comment from leading whitespace 2
test text object deletes single line comment from leading whitespace 3
test text object deletes adjoining multi-line block comments 2
test text object deletes JavaDoc comment from leading whitespace
test text object deletes single line comments separated by whitespace
test text object deletes JavaDoc comment and adjoining comments separated by whitespace
test text object deletes single line comment from trailing whitespace
test text object deletes disjointed single line comments from whitespace

@AlexPl292
Copy link
Member

This depends if the new behavior matches the behavior of the vim-commentary extension. You can install the plugin on Vim and check if it works the same.
I've checked a few tests, and it looks like the current behavior in tests matches the Vim. For example, test text object deletes single line comment from trailing whitespace is correct. Also, vim seems not to handle block comments, but if they'll be replaced with a simple // comment test text object deletes JavaDoc comment from leading whitespace also seems to have a correct processing.

@CCCC-L
Copy link
Author

CCCC-L commented Feb 26, 2025

This depends if the new behavior matches the behavior of the vim-commentary extension. You can install the plugin on Vim and check if it works the same. I've checked a few tests, and it looks like the current behavior in tests matches the Vim. For example, test text object deletes single line comment from trailing whitespace is correct. Also, vim seems not to handle block comments, but if they'll be replaced with a simple // comment test text object deletes JavaDoc comment from leading whitespace also seems to have a correct processing.

Yes, in the vim-commentary plugin, the empty lines above and below the comment are also considered as part of the comment. However, in neoVim, this is not the case. Neovim does not consider the empty lines above and below the comment as part of the comment.

For example, in the following text, if the cursor is on the first line, when you press dgc, it will not delete both comments. Instead, it will only delete // commentary1.

// commentary1

// commentary2

@AlexPl292
Copy link
Member

Okay, I see what you mean.
For us it looks like the neovim approach is more expected. Let's make it like in neovim and update the tests accordingly.

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.

2 participants