chrisbra / matchit

The matchit plugin from Vim
61 stars 9 forks source link

`]%` ignores some tokens #1

Closed lacygoill closed 6 years ago

lacygoill commented 6 years ago

Hello,

I open this issue because you asked to open issues for the various problems discussed on this question on stackexchange.

Currently, it seems that ]% only moves the cursor on a closed parenthesis, and ignores all tokens defined in b:match_words. The issue may come from the line 695:

 let closepat = substitute(closepat, ',', '\\|', 'g')

The last step producing the pattern describing the end token involves a substitution which replaces the commas (separating the groups of tokens inside b:match_words) with alternations, but not the colons (separating the tokens inside a group). So, maybe this line would work better:

let closepat = substitute(closepat, '[,:]', '\\|', 'g')

I won't open an issue for the [% motion, because it seems you have already fixed it in these 2 commits:

https://github.com/chrisbra/matchit/commit/68b2f2224d8a13eb2a32e543d9847a4fc364e619 https://github.com/chrisbra/matchit/commit/ecff10ab2bb4fba4f1926d0e7716b930d9f00b80

chrisbra commented 6 years ago

Hi, I am holding back, until it is clear, which is the final upstream repository for the matchit plugin. See benjifisher/matchit.zip#10

k-takata commented 6 years ago

I created a fix for this in my repository, and I'm going to create some PRs after #4 and #5 are merged. However, I'm wondering how ]% should work for multiple patterns like \<if\>:\<else\>:\<endif\>.

if
  | <- assuming the cursor is here.
else
endif

If ]% is pressed, which should the cursor go to? else or endif? With my current implementation, it goes to else.

lacygoill commented 6 years ago

@k-takata In this scenario, I would expect the cursor to move to the nearest keyword, here else.

chrisbra commented 6 years ago

Hi @k-takata if you like to have your fixes merged, you can now create a new PR then.

k-takata commented 6 years ago

I think this is fixed with #8.