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

Faulty matching #41

Closed
tusj opened this issue Oct 28, 2014 · 3 comments
Closed

Faulty matching #41

tusj opened this issue Oct 28, 2014 · 3 comments
Labels

Comments

@tusj
Copy link

tusj commented Oct 28, 2014

I wanted to add a text object to match numbers with an optional decimal part, (eg 123 and 123.23). It seemed to work nicely, untill I found out that for certain use cases the pattern matching matches lots of extra, non-digit characters in order to find a match. If I test the pattern with a normal / search, I get the desired result.

    call textobj#user#plugin('number', {
    \   'real': {
    \     'pattern': '\v\d+(\.\d+)?',
    \     'select': ['an', 'in'],
    \   }
    \ })

I tested by launching vim as vim -u NONE, setting rpt+=~/.vim/bundle/vim-textobj-user, and souring the above code.

Then, for a test file like

2abc
         2.    abc2232

Then, by pressing either vin or van:
I get match from the first to the second number 2 if I place the cursor in front of the second number 2.
I also get a match from the second number 2 to the end if I place the cursor on the second number two.
That is, I get these matches:

<2abc
          2>

and

2abc
       <2.   abc2232>

My current vim version is 7.4.473.

I should also add that I am new to textobj-user.

@kana
Copy link
Owner

kana commented Oct 29, 2014

Thank you for the report. I'll investigate it later.

@kana
Copy link
Owner

kana commented Oct 29, 2014

It is a bug of vim-textobj-user. The problem happens if a desired object is a single character. I'll try to fix it later.

@kana kana added the bug label Oct 29, 2014
@tusj
Copy link
Author

tusj commented Oct 29, 2014

Thanks!

@kana kana closed this as completed in 2bf18f7 Oct 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants