-
Notifications
You must be signed in to change notification settings - Fork 409
Closed
Description
Issue
As discovered in PR #2107 in the comment here, the labels and captions of environments within another environment are incorrectly displayed in the top-level fold, even if the top-level fold has its own labels and captions.
Observed Behaviour
\begin{thm}[Theorem 1]
\label{thm:theorem_1}
\caption{theorem 1 caption}
...
\begin{figure}
\label{fig:figure_1}
...
\caption{figure 1 caption}
\end{figure}
...
\end{thm}is currently folded as:
\begin{thm}[Theorem 1] figure 1 caption (fig:figure_1)
Expected Behaviour
instead of the proper folding:
\begin{thm}[Theorem 1] theorem 1 caption (thm:theorem_1)
This is caused by the fold_parse_label and fold_parse_caption functions here:
vimtex/autoload/vimtex/fold/envs.vim
Lines 118 to 142 in a064c48
| function! s:folder.parse_label() abort dict " {{{1 | |
| let i = v:foldend | |
| while i >= v:foldstart | |
| if getline(i) =~# '^\s*\\label' | |
| return matchstr(getline(i), '^\s*\\label\%(\[.*\]\)\?{\zs.*\ze}') | |
| end | |
| let i -= 1 | |
| endwhile | |
| return '' | |
| endfunction | |
| " }}}1 | |
| function! s:folder.parse_caption(line) abort dict " {{{1 | |
| let i = v:foldend | |
| while i >= v:foldstart | |
| if getline(i) =~# '^\s*\\caption' | |
| return matchstr(getline(i), | |
| \ '^\s*\\caption\(\[.*\]\)\?{\zs.\{-1,}\ze\(}\s*\)\?$') | |
| end | |
| let i -= 1 | |
| endwhile | |
| " If no caption found, check for a caption comment | |
| return matchstr(a:line,'\\begin\*\?{.*}\s*%\s*\zs.*') | |
| endfunction |
Fixing this will involve rewriting the function to not search subfolds.
Output from VimtexInfo
Should be irrelevant in this case, but for the sake of consistency:
System info
OS: Manjaro Linux
Vim version: VIM 8.2 (1-3171)
Has clientserver: true
Servername: undefined (vim started without --servername)
Metadata
Metadata
Assignees
Labels
No labels