From be6d03b7cc5bf784e85d51de803cb6d599e49bc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Sun, 11 Sep 2016 23:26:53 +0200 Subject: [PATCH] Fix #544: Handle long lines while formatting --- autoload/vimtex/format.vim | 6 ++++++ test/vader/format.vader | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/autoload/vimtex/format.vim b/autoload/vimtex/format.vim index a96a983..9190cde 100644 --- a/autoload/vimtex/format.vim +++ b/autoload/vimtex/format.vim @@ -110,6 +110,12 @@ function! s:format(top, bottom) " {{{1 continue endif + " Handle long lines + if len(l:line) > s:textwidth + let l:bottom += s:format_build_lines(l:current, l:mark) + let l:mark = l:current-1 + endif + if l:line =~# s:border_end if l:current < l:mark let l:bottom += s:format_build_lines(l:current+1, l:mark) diff --git a/test/vader/format.vader b/test/vader/format.vader index bdd85bc..08de02f 100644 --- a/test/vader/format.vader +++ b/test/vader/format.vader @@ -174,3 +174,29 @@ Expect tex (Verify): is an approximation whose coefficients become \emph{non-universal} (dependent on intial conditions) and \emph{time-dependent}. +Given tex (Format: Enumerate env): + \begin{enumerate}[(i)] + \item xxxxxxxxxx xx xxxxxx xxxxxx xx xxxxxxxxxx xxxxxxx xxxxxxx xxx + xxxxxxxxxx xxxxxxxxxx xxxxxxx xxxxxxxxxxxxxxx xxxx xxxxx xxxxxxxxxxx xxxxxxx + xxxxxxxxxxxx xxxx xxxxxxx xxxxxxxxx xxxxxxxxx xxxxxxxxxxx xxxxxxxxx xxxxxxxxx + xx xxxxxxxxx + \item xxxxxx xxxxxxxxxxxxx xxxxxxxxxx xxxxxxxxx xxxxxx xxxxxxxxxxxxxx xxx + xxxxxxxxxxxxxx xxxxxxxxx xxxxxxxxxx xx xxxxxxxxxx xxxxxxxxxx xxxxxxxxxxx + xxxxxxxxxxxxxxxxx xxxxx xxxxxxx + \end{enumerate} + +Do (Format text): + gqG + +Expect tex (Verify): + \begin{enumerate}[(i)] + \item xxxxxxxxxx xx xxxxxx xxxxxx xx xxxxxxxxxx xxxxxxx xxxxxxx xxx + xxxxxxxxxx xxxxxxxxxx xxxxxxx xxxxxxxxxxxxxxx xxxx xxxxx xxxxxxxxxxx + xxxxxxx xxxxxxxxxxxx xxxx xxxxxxx xxxxxxxxx xxxxxxxxx xxxxxxxxxxx xxxxxxxxx + xxxxxxxxx xx xxxxxxxxx + \item xxxxxx xxxxxxxxxxxxx xxxxxxxxxx xxxxxxxxx xxxxxx xxxxxxxxxxxxxx xxx + xxxxxxxxxxxxxx xxxxxxxxx xxxxxxxxxx xx xxxxxxxxxx xxxxxxxxxx xxxxxxxxxxx + xxxxxxxxxxxxxxxxx xxxxx xxxxxxx + \end{enumerate} + +