-
Notifications
You must be signed in to change notification settings - Fork 391
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
Jump to previous/next math zone #1818
Conversation
…g delimiter from matching for $, $$
I've made some relatively minor comments to the code. As a general comment: Good work! I think you are quite close. I think it would be very good to add some tests. I think it should not be so hard. Something like this:
It should suffice, and you should be able to run the tests with |
@lervag I have hit an issue with the following \begin{equation}
1 + 1 = 2
\end{equation}
\( 1 + 1 = 2 \)
\[
1 + 1 = 2
\] Notation used to represent position: (line, col)
Here's an asciinema showing the same. P.S. I used the following modified version function! vimtex#syntax#stack(...) abort " {{{1
let l:pos = a:0 > 0 ? [a:1, a:2] : [line('.'), col('.')]
if mode() ==# 'i'
let l:pos[1] -= 1
endif
call map(l:pos, 'max([v:val, 1])')
if a:0 > 0
echo "In syntax#stack" l:pos synstack(l:pos[0], l:pos[1])
endif
return map(synstack(l:pos[0], l:pos[1]), "synIDattr(v:val, 'name')")
endfunction |
I'll look into it! I've also made a couple of very minor, pedantic comments (sorry!). |
If the current "match" is any of |
Yes, I was thinking the same. While writing the tests I realized that 1 $\alpha + \beta$
2 $\gamma$ If the cursor is on the last column of line 2 (ending delimiter), then Another example 1 $\alpha + \beta$
2
3 $$\gamma$$ In this case if the cursor is on the last column of line 3 (right delimiter), the search takes us one column left because I have pushed a commit, where I am handling the edge cases by using regex subgroups and a branching logic, and I think I have done it in a crude way. If there's a better way of handling these cases, or if there are other edge cases you can think of, please let me know. |
@lervag I have added tests as you suggested. When I check them manually, they run fine but when I run |
Yes, I expected these. These have been head scratchers in many other cases as well. I'm glad to see you've figured out a good way to solve it!
I appreciate the use of the
The solution is obvious when you see it: this feature requires This leaves two minor fixes as mentioned above, and then finally the documentation:
|
Thanks a lot.
Fixed.
Aah, I should have realized that. Fixed.
Please let me know if you want me to make anymore changes. I am doing some fine tuning, will let you know once I think it is ready to be merged. :) |
Did you fix it in a different manner, perhaps?
No, this looks good. Thanks!
Sounds good. |
@lervag I have fixed a regex bug that I had introduced while changing the implementation. I have also changed the behavior of the motion when the I have checked the motions on some of my latex files as well, and I think it is ready to be merged now. Please let me know what you think of it. |
This adds the motions [n, [N, ]n, ]N for moving to the beginning or end of the previous/next math zone. refer: #1818
Thanks! I've now merged this. It seems to work well also in my tests, and at least it should not break anything. I've made some minor modifications/changes, nothing essential. Again, thank you very much for this, it seems to be a useful feature and your work is of high quality! Very well done! |
Your modifications are indeed improvements on what I wrote. Thanks for helping me in adding the feature. 👍 |
My pleasure :) |
Fixes #1810.