Ref #511: respect indent of first line during formatting
This commit is contained in:
parent
4e7fd6e04b
commit
575b9b018f
@ -55,7 +55,9 @@ function! vimtex#format#formatexpr() " {{{1
|
|||||||
let l:bottom = s:format(l:top, l:bottom)
|
let l:bottom = s:format(l:top, l:bottom)
|
||||||
|
|
||||||
" Ensure proper indentation
|
" Ensure proper indentation
|
||||||
silent! execute printf('normal! %sG=%sG', l:top, l:bottom)
|
if l:top < l:bottom
|
||||||
|
silent! execute printf('normal! %sG=%sG', l:top+1, l:bottom)
|
||||||
|
endif
|
||||||
|
|
||||||
" Check if any lines have changed
|
" Check if any lines have changed
|
||||||
let l:lines_new = getline(l:top, l:bottom)
|
let l:lines_new = getline(l:top, l:bottom)
|
||||||
@ -139,7 +141,7 @@ function! s:format_build_lines(start, end) " {{{1
|
|||||||
" Add the words in properly indented and formatted lines
|
" Add the words in properly indented and formatted lines
|
||||||
"
|
"
|
||||||
let l:lnum = a:start-1
|
let l:lnum = a:start-1
|
||||||
let l:current = repeat(' ', VimtexIndent(a:start))
|
let l:current = repeat(' ', indent(a:start))
|
||||||
for l:word in l:words
|
for l:word in l:words
|
||||||
if len(l:word) + len(l:current) > s:textwidth
|
if len(l:word) + len(l:current) > s:textwidth
|
||||||
call append(l:lnum, substitute(l:current, '\s$', '', ''))
|
call append(l:lnum, substitute(l:current, '\s$', '', ''))
|
||||||
|
Loading…
Reference in New Issue
Block a user