-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Have ci[ look for next [ like ci" does for next " #8670
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a test for this change?
I've added a test, though I'm not especially familiar with Vimscript so hopefully it's acceptable. Running the test locally, it passes with my changes and fails without. |
Hi,
On Fri, Jul 30, 2021 at 9:26 AM Connor Lane Smith ***@***.***> wrote:
I've added a test, though I'm not especially familiar with Vimscript so
hopefully it's acceptable. Running the test locally, it passes with my
changes and fails without.
Thanks for adding the test. The test looks good to me.
Regards,
Yegappan
|
Codecov Report
@@ Coverage Diff @@
## master #8670 +/- ##
========================================
Coverage 90.06% 90.07%
========================================
Files 150 146 -4
Lines 169172 169476 +304
========================================
+ Hits 152372 152651 +279
- Misses 16800 16825 +25
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
I tried your patch and I've noticed a difference in behavior when comparing With the cursor on the first line:
doing
So
doing I don't mind but I thought I would point it out, especially since you don't have tests with multiple lines. |
di" and di[ work differently, because the double quote does not indicate a direction. Therefore it only works in one line, assuming that the first double quote in the line is the start of the object. For a square bracket we can start anywhere, and know that [ is the start and ] is the end. |
Problem: ci" finds following string but ci< and others don't. Solution: When not inside an object find the start. (Connor Lane Smit, closes vim#8670)
Problem: ci" finds following string but ci< and others don't. Solution: When not inside an object find the start. (Connor Lane Smit, closes vim/vim#8670) vim/vim@b9115da
Problem: ci" finds following string but ci< and others don't. Solution: When not inside an object find the start. (Connor Lane Smit, closes vim/vim#8670) vim/vim@b9115da
Problem: ci" finds following string but ci< and others don't. Solution: When not inside an object find the start. (Connor Lane Smit, closes vim/vim#8670) vim/vim@b9115da
…'t (#16324) Problem: ci" finds following string but ci< and others don't. Solution: When not inside an object find the start. (Connor Lane Smit, closes vim/vim#8670) vim/vim@b9115da
…'t (neovim#16324) Problem: ci" finds following string but ci< and others don't. Solution: When not inside an object find the start. (Connor Lane Smit, closes vim/vim#8670) vim/vim@b9115da
Change in vim: vim/vim@b9115da vim/vim#8670 VIM-2699
In runtime/doc/todo.txt is a known issue:
For instance, if you are at the beginning of a line that reads
#include "foo.h"
thenci"
will change the contents of the string, but if it reads#include <foo.h>
thenci<
will fail to find and change the contents of the angle brackets.This patch has
ci[
search forward for a bracket likeci"
does.There are two commits. The first is sufficient for a plain
i[
or1i[
, but behaves a little strangely with numbers greater than 1. Specifically,di[
beforea[b[c]d]e
leavesa[]e
, and2di[
leavesa[b[]d]e
, but any odd does the same as 1, and any even 2. This is just an artefact of the way it searches for a match.i"
doesn't have this problem as 2+ is just a single special case.The second commit fixes this so that
3i[
for example will enter the third nested bracket it finds, in a sort of inside-out version of what it would do if you were inside the brackets rather than outside of them. A higher number than there are nested brackets will fail. It's not entirely clear that this is the ideal behaviour, and it's a bit more code which is why I've kept it separate, but it seemed fairly reasonable.This patch does not handle tag-blocks (
it
), only 'regular' blocks of '(', '{', etc.Please let me know if there are any issues. Thanks.