-
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
inner environment text-object fails on { being the first char after \begin{} #2160
Comments
And |
|
I think we need to make some heuristic, but I'm not sure if it is safe to do so. |
You would get the same problem with \begin{minted}
[
"contacts": [
{
"source_id": "mandatory"
}
]
]
\end{minted} The point, as hinted, is that VimTeX parses \documentclass{article}
\usepackage{minted}
\begin{document}
\begin{minted}
[
numbersep=5mm,
linenos=true,
fontsize=\footnotesize,
breaklines
]
{
json
}
{
"contacts": [
{
"source_id": "mandatory"
}
]
}
\end{minted}
\end{document} My point is only to show that it really is hard to properly parse this stuff. And I don't know if I'm able to really find a good way to make it work reliably. |
In my last example: I think we can both agree that the inner part of the environment starts at So, at least the issue is now fully understood and explained. It remains to see if it is possible to suggest any solution. I'm afraid it is going to be hard.. :\ |
Perhaps a workaround is to add an empty line first? Or a json comment? |
I can totally understand it is not a trivial thing to do, indeed.
|
I am thinking of non-greedy |
One additional thing: |
Yes; for the exact same reason. |
It is more or less impossible to write a perfect parser here, I believe. To do so, we need to know the exact signature of each command. But we don't. :\ |
In some cases, non-greedy would be perfect. In others, it would not be good and you would have to adjust. |
The text object function is here: vimtex/autoload/vimtex/text_obj.vim Lines 103 to 168 in 1861f3c
Here the inner object is narrowed: vimtex/autoload/vimtex/text_obj.vim Lines 285 to 289 in 1861f3c
The parser for environment delimiters is here: vimtex/autoload/vimtex/delim.vim Lines 538 to 572 in 1861f3c
|
This is the outer delimiter parser, the starting point of the parser: vimtex/autoload/vimtex/delim.vim Lines 426 to 514 in 1861f3c
|
I have to admit I'm tempted to not spend more time on this, as I can't see any clear strategy for fixing this that won't break other functionality. :\ |
You're probably right. I can only think of a newline-like Anyway, I can agree there is no clear solution to the problem. |
As a workaround I can use a |
So, just to be clear: I believe the current implementation works "as expected" most of the time, and that your specific example is simply a good example of where it does not work as expected.
I agree with that, actually, so I'll look into it. |
I agree; just pushed a fix for that.
Ah, yes, that seems like an ok workarond. For other readers: |
Thx, empty line separator looks like a good solution for this. |
Description
No way to visually select or delete inner environment with
vie
,die
for the code block of the json source.Steps to reproduce
vim -u minimal.vim minimal.tex
"contacts"
vie
minimal.tex
Expected behavior
Contents of the
minted
environment is visually selected:Actual behavior
A single char is selected at the end of the environment:
Do you use a latexmkrc file?
No
VimtexInfo
The text was updated successfully, but these errors were encountered: