Skip to content

Commit 9ca13fe

Browse files
committed
merge: make toggle_math star aware
refer: #3213
2 parents 088ad45 + ca9ebe6 commit 9ca13fe

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

autoload/vimtex/env.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ function! vimtex#env#toggle_math() abort
365365

366366
let l:current = get(l:open, 'name', l:open.match)
367367
let l:target = get(g:vimtex_env_toggle_math_map, l:current, '$')
368+
\ .. get(l:open, 'starred', 0) ? '*' : ''
368369

369370
call vimtex#env#change(l:open, l:close, l:target)
370371
endfunction

test/test-env/test-toggle-math.tex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
1+1=2
1515
\end{equation}
1616

17+
\begin{equation*}
18+
1+1=2
19+
\end{equation*}
20+
1721
World
1822

1923
\begin{equation}

test/test-env/test-toggle-math.vim

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ nnoremap q :qall!<cr>
77
88
silent edit test-toggle-math.tex
99

10-
normal! 20G
10+
normal! 24G
1111
call vimtex#env#toggle_math()
1212
call assert_equal([
1313
\ 'World',
1414
\ '',
1515
\ '$f(x) = 1 + e^x$',
1616
\ '',
1717
\ '\end{document}',
18-
\], getline(17, 21))
18+
\], getline(21, 25))
1919

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

27+
let g:vimtex_env_toggle_math_map = {
28+
\ 'equation': 'align',
29+
\}
30+
31+
normal! 11G
32+
call vimtex#env#toggle_math()
33+
call assert_equal([
34+
\ '\begin{align}',
35+
\ ' 1+1=2',
36+
\ '\end{align}',
37+
\], getline(10, 12))
38+
39+
normal! 15G
40+
call vimtex#env#toggle_math()
41+
call assert_equal([
42+
\ '\begin{align*}',
43+
\ ' 1+1=2',
44+
\ '\end{align*}',
45+
\], getline(14, 16))
46+
2747
call vimtex#test#finished()

0 commit comments

Comments
 (0)