Skip to content

ts$ on an equation environment can be slow or hang #2432

@gapato

Description

@gapato

Description

On neovim 0.7.2, if the document has a lot of math environments and ones tries to toggle the delimiter using ts$ on an equation environment near the end of the docuemnt, it can be very slow or hang. It works fine when acting on $$ or [ ] delimiters. I sometimes get a trace like this:

E132: Function call depth is higher than 'maxfuncdepth'                                                                                                                                                                                                                           
Error detected while processing function <SNR>93_operator_function[6]..vimtex#env#toggle_math[1]..vimtex#env#get_surrounding[18]..vimtex#delim#get_surrounding[7]..vimtex#delim#get_prev[1]..<SNR>90_get_delim[77]..<SNR>90_parser_tex[46].. [...]                                                                                                
                                                                                                                                                                                                                                                            
E712: Argument of extend() must be a List or Dictionary                                                                                                                                                                                                                           
Error detected while processing function <SNR>93_operator_function[6]..vimtex#env#toggle_math[1]..vimtex#env#get_surrounding[18]..vimtex#delim#get_surrounding[7]..vimtex#delim#get_prev[1]..<SNR>90_get_delim[77]..<SNR>90_parser_tex[46].. [...]

neovim --version

NVIM v0.7.2
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wp,-U_FORTIFY_SOURCE -Wp,-D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -Wimplicit-fallthrough -Wsuggest-attribute=pure -Wsuggest-attribute=const -Wsuggest-attribute=malloc -Wsuggest-attribute=cold -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/builddir/build/BUILD/neovim-0.7.2/redhat-linux-build/config -I/builddir/build/BUILD/neovim-0.7.2/src -I/usr/include -I/usr/include/luajit-2.1 -I/builddir/build/BUILD/neovim-0.7.2/redhat-linux-build/src/nvim/auto -I/builddir/build/BUILD/neovim-0.7.2/redhat-linux-build/include
Compiled by mockbuild@koji


Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

~/.config/nvim/init.vim

lua require('plugins')

~/.config/nvim/lua/plugins.lua

return require('packer').startup(function()
  -- Packer can manage itself
  use 'wbthomason/packer.nvim'

  -- Simple plugins can be specified as strings
  use 'lervag/vimtex'
end)

Steps to reproduce

minimal.txt

  1. mv minimal.txt minimal.tex
  2. nvim minimal.tex
  3. G
  4. ts$

Expected behavior

One should get $equation$ on the last line instantaneously.

Actual behavior

Vim hangs or needs a long time to change the math delimiter

Do you use a latexmkrc file?

No / not relevant here

VimtexInfo

1 System info:                                                                                                                                                                                                                                                                
    2   OS: Linux 5.18.9-200.fc36.x86_64                                                                                                                                                                                                                                          
    3   Vim version: NVIM v0.7.2                                                                                                                                                                                                                                                  
    4   Has clientserver: true                                                                                                                                                                                                                                                    
    5   Servername: /tmp/nvimUKR8nA/0                                                                                                                                                                                                                                             
    6                                                                                                                                                                                                                                                                             
    7 VimTeX project: minimal                                                                                                                                                                                                                                                     
    8   base: minimal.tex                                                                                                                                                                                                                                                         
    9   root: .                                                                                                                                                                                                                        
   10   tex: .                                                                                                                                                                                                             
   11   main parser: current file                                                                                                                                                                                                                                                 
   12   document class:                                                                                                                                                                                                                                                           
   13   compiler: latexmk                                                                                                                                                                                                                                                         
   14     engine: -pdf                                                                                                                                                                                                                                                            
   15     options:                                                                                                                                                                                                                                                                
   16       -verbose                                                                                                                                                                                                                                                              
   17       -file-line-error                                                                                                                                                                                                                                                      
   18       -synctex=1                                                                                                                                                                                                                                                            
   19       -interaction=nonstopmode                                                                                                                                                                                                                                              
   20     callback: 1                                                                                                                                                                                                                                                             
   21     continuous: 1                                                                                                                                                                                                                                                           
   22     executable: latexmk                                                                                                                                                                                                                                                     
   23   viewer: General                                                                                                                                                                                                                                                           
   24   qf method: LaTeX logfile

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions