Skip to content

Commit

Permalink
fix: tse shouldn't toggle \begin{document}
Browse files Browse the repository at this point in the history
refer: #2210
  • Loading branch information
lervag committed Oct 18, 2021
1 parent 0824ade commit 05dbb2c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
3 changes: 2 additions & 1 deletion autoload/vimtex/env.vim
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ endfunction

function! vimtex#env#toggle_star() abort " {{{1
let [l:open, l:close] = vimtex#delim#get_surrounding('env_tex')
if empty(l:open) | return | endif
if empty(l:open)
\ || l:open.name ==# 'document' | return | endif

call vimtex#env#change(l:open, l:close,
\ l:open.starred ? l:open.name : l:open.name . '*')
Expand Down
14 changes: 14 additions & 0 deletions test/test-env/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
MYVIM ?= nvim --headless

INMAKE := 1
export INMAKE

TESTS := $(wildcard *.vim)
TESTS := $(TESTS:.vim=)

.PHONY: test $(TESTS)

test: $(TESTS)

$(TESTS):
@$(MYVIM) -u $@.vim
6 changes: 6 additions & 0 deletions test/test-env/test-toggle-star.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
\documentclass{minimal}
\begin{document}

Hello World!

\end{document}
14 changes: 14 additions & 0 deletions test/test-env/test-toggle-star.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
set nocompatible
set runtimepath^=../..
filetype plugin on
syntax on

nnoremap q :qall!<cr>
silent edit test-toggle-star.tex

normal! 4G
call vimtex#env#toggle_star()
call assert_equal('\end{document}', getline('$'))

call vimtex#test#finished()

0 comments on commit 05dbb2c

Please sign in to comment.