Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion autoload/vimtex/env.vim
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,8 @@ function! vimtex#env#toggle_math() abort
let l:current = get(l:open, 'name', l:open.match)
let l:target = get(g:vimtex_env_toggle_math_map, l:current, '$')

call vimtex#env#change(l:open, l:close, l:target)
call vimtex#env#change(l:open, l:close,
\ get(l:open, 'starred', 0) ? l:target . '*' : l:target)
endfunction


Expand Down
4 changes: 4 additions & 0 deletions test/test-env/test-toggle-math.tex
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
1+1=2
\end{equation}

\begin{equation*}
1+1=2
\end{equation*}

World

\begin{equation}
Expand Down
24 changes: 22 additions & 2 deletions test/test-env/test-toggle-math.vim
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ nnoremap q :qall!<cr>

silent edit test-toggle-math.tex

normal! 20G
normal! 24G
call vimtex#env#toggle_math()
call assert_equal([
\ 'World',
\ '',
\ '$f(x) = 1 + e^x$',
\ '',
\ '\end{document}',
\], getline(17, 21))
\], getline(21, 25))

normal! 7G
call vimtex#env#toggle_math()
Expand All @@ -24,4 +24,24 @@ call assert_equal([
\ '\end{proof}',
\], getline(5, 6))

let g:vimtex_env_toggle_math_map = {
\ 'equation': 'align',
\}

normal! 11G
call vimtex#env#toggle_math()
call assert_equal([
\ '\begin{align}',
\ ' 1+1=2',
\ '\end{align}',
\], getline(10, 12))

normal! 15G
call vimtex#env#toggle_math()
call assert_equal([
\ '\begin{align*}',
\ ' 1+1=2',
\ '\end{align*}',
\], getline(14, 16))

call vimtex#test#finished()