Skip to content
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

strange bug with ts$ #2998

Open
ces42 opened this issue Sep 12, 2024 · 2 comments
Open

strange bug with ts$ #2998

ces42 opened this issue Sep 12, 2024 · 2 comments
Labels

Comments

@ces42
Copy link
Contributor

ces42 commented Sep 12, 2024

Description

I stumbled upon this strange bug. It seems to be very rare so rather low-priority. I can try to look into what's happening once I'm less busy...

Steps to reproduce

  1. put this into a tex file

    \[
        \{x \vert \text{$1$ $2$ $3$}\}
        y
    \]
  2. move the cursor to y and do ts$

Expected behavior

\[ ... \] should turn to \begin{equation} ... \end{equation}

Actual behavior

nothing happens. If the cursor is in the first line of the displaymath everything seems to work fine. If I delete the $3$ things also work fine.

Do you use a latexmkrc file?

no

VimtexInfo

System info:
  OS: Ubuntu 23.10
  Vim version: NVIM v0.11.0-dev-650+ge961627956
  Has clientserver: true
  Servername: /run/user/1000/nvim.370829.0

VimTeX project: tex
  base: tex.tex
  root: /home/ca/build/vimtex/test/perf-syntax
  tex: /home/ca/build/vimtex/test/perf-syntax/tex.tex
  main parser: fallback current file
  document class: 
  compiler: latexmk
    engine: -pdf
    options:
      -verbose
      -file-line-error
      -synctex=1
      -interaction=nonstopmode
    callback: 1
    continuous: 1
    executable: latexmk
  viewer: General
  qf method: LaTeX logfile
@ces42 ces42 added the bug label Sep 12, 2024
@lervag
Copy link
Owner

lervag commented Sep 18, 2024

Thanks! That's definitely an edge case! The reason for this is here:

\ 'env_math': 3,

I.e., I've specified a maximum number of "iterations" in the loop that looks for the correct surrounding delimiters/environment. And at some time, ages ago, I found that this search was slow for math delimiters because there are many of them and the regexes are quite complex. So, I decided to use a very strict and low maximum number here.

It may definitely be possible to relax this. I believe it could be safe and that I may have been a little bit too conservative here. But I don't want to change it much, and if someone complains that VimTeX is suddenly more laggy I would not hesitate to revert such a change. What do you think?

@lervag
Copy link
Owner

lervag commented Sep 18, 2024

See also #2432; this is where the strict current setting was motivated and added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants