F9 \ref completion fails when a \label is inside a figure environment (fixed in 1.10.0)

Bug #1831989 reported by James Womack
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
vim-latexsuite (Ubuntu)
In Progress
Undecided
Unassigned

Bug Description

Release
=======
Description: Ubuntu 18.04.2 LTS
Release: 18.04

Package version
===============
vim-latexsuite:
  Installed: 1:1.9.0-1

Bug description
===============
When using (G)Vim 8.0 with latex-suite 1.9.0 on Ubuntu 18.04 LTS, with latex-suite installed from Ubuntu's package repositories, using the F9 key for \ref completion no longer works correctly in some circumstances.

This occurs when I have a \label within a figure environment, in which case a Python error message briefly appears, then vanishes leaving an empty __OUTLINE__ window. Removing the \label from the figure environment restores the usual behaviour (showing labels to select for insertion).

MWE:

\documentclass{article}

\begin{document}
\section{First}
\label{sec:first}

\subsection{Second}
\label{subsec:second}

\ref{sec:first}
\ref{}
  \begin{figure}
    \label{fig:figure}
  \end{figure}
\end{document}

If I switch to insert mode and press F9 within the curly brackets for the \ref command in the above example, then the error below occurs and an empty __OUTLINE__ window is shown.

"__OUTLINE__" [New File]
line 23:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/jcw1u14/.vim/ftplugin/latex-suite/outline.py", line 191, in main
    return getSectionLabels(lineinfo, label_prefix=label_prefix)
  File "/home/jcw1u14/.vim/ftplugin/latex-suite/outline.py", line 162, in getSectionLabels
    sections[0], sectypes[1:], section_prefix, label_prefix)
  File "/home/jcw1u14/.vim/ftplugin/latex-suite/outline.py", line 170, in getSectionLabels
    section_prefix + ('%d.' % sec_num), label_prefix)
  File "/home/jcw1u14/.vim/ftplugin/latex-suite/outline.py", line 170, in getSectionLabels
    section_prefix + ('%d.' % sec_num), label_prefix)
  File "/home/jcw1u14/.vim/ftplugin/latex-suite/outline.py", line 162, in getSectionLabels
    sections[0], sectypes[1:], section_prefix, label_prefix)
  File "/home/jcw1u14/.vim/ftplugin/latex-suite/outline.py", line 150, in getSectionLabels
    return getSectionLabels_Root(lineinfo, section_prefix, label_prefix)
  File "/home/jcw1u14/.vim/ftplugin/latex-suite/outline.py", line 100, in getSectionLabels_Root
    cm = re.search(r'\caption(\[.*?\]\s*)?{(.*?)}', prev_txt)
  File "/usr/lib/python3.6/re.py", line 182, in search
    return _compile(pattern, flags).search(string)
  File "/usr/lib/python3.6/re.py", line 301, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/usr/lib/python3.6/sre_compile.py", line 562, in compile
    p = sre_parse.parse(p, flags)
  File "/usr/lib/python3.6/sre_parse.py", line 855, in parse
    p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)
  File "/usr/lib/python3.6/sre_parse.py", line 416, in _parse_sub
    not nested and not items))
  File "/usr/lib/python3.6/sre_parse.py", line 502, in _parse
    code = _escape(source, this, state)
  File "/usr/lib/python3.6/sre_parse.py", line 401, in _escape
    raise source.error("bad escape %s" % escape, len(escape))
sre_constants.error: bad escape \c at position 0
line 24:
Traceback (most recent call last):
  File "<string>", line 1, in <module>

This is missing the last line of the message, since I needed to capture it by resizing the window to make the error message paged.

If I comment out the \label in the figure environment, then press F9 in the same place, then the error does not occur and the __OUTLINE__ window contains the expected entries for the labelled sections.

According to discussion on the vim-latex github, this issue was fixed 2 years ago in commit 7d60db0 (https://github.com/vim-latex/vim-latex/commit/7d60db044cc195ca26c97e3d0a2bde270bfd8f8f).

See https://github.com/vim-latex/vim-latex/issues/135 for the full discussion of the issue.

The fix should be included in the latest release of Vim LaTeX-suite on github (1.10.0). Can this package be upgraded to the latest release?

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in vim-latexsuite (Ubuntu):
status: New → Confirmed
Revision history for this message
Johann Felix Soden (johfel) wrote :

Thanks for reporting. vim-latexsuite has been updated to 1.10.0. Please check if the bug has been solved in the latest version and close this report.

Changed in vim-latexsuite (Ubuntu):
status: Confirmed → In Progress
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.