latex-lsp / texlab

An implementation of the Language Server Protocol for LaTeX
GNU General Public License v3.0
1.56k stars 52 forks source link

document symbols numbering as in toc #1251

Closed nolanking90 closed 1 month ago

nolanking90 commented 1 month ago

Fix #910 Created new command variants for \contentline and \numberline, and added section_numbers to aux doc data struct. Now, uses the numbering from the table of contents to number sections in the documents symbols list. This PR changes the expected output of the document symbol unit test, so the test is updated as well.

\documentclass{article}

\begin{document}

\section{First Section}\label{asec:outer} % 1 Section
    \begin{equation}\label{eq:myEQ}
        1 + 1 = 2
    \end{equation}

    \subsection{Subsection}{First Subsection} % 1.1 Subsection

\section{Another Section} % 2 Section'
    \subsection{Dummy} % 2.1 Dummy
    \subsection*{Subsection'}\label{sec:inner} % Subsection'

\end{document}

produces the following document symbols

main.tex|5 col 24| [Module] 1 First Section
main.tex|6 col 18| [Constant] Equation (1)
main.tex|10 col 2| [Module] 1.1 Subsection
main.tex|12 col 1| [Module] 2 Another Section
main.tex|13 col 2| [Module] 2.1 Dummy
main.tex|14 col 27| [Module] Subsection'