summaryrefslogtreecommitdiff
path: root/src/testdir/test_indent.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-12-06 19:51:01 +0000
committerBram Moolenaar <Bram@vim.org>2021-12-06 19:51:01 +0000
commitecabb511074b3f56cdd5067553c947a291d04e17 (patch)
tree35604ce180a874dc124450a0e0e9fdeb7658e832 /src/testdir/test_indent.vim
parent3e55a973b5cab5823335e24b7e4885429c885921 (diff)
downloadvim-git-ecabb511074b3f56cdd5067553c947a291d04e17.tar.gz
patch 8.2.3754: undesired changing of the indent of the first formatted linev8.2.3754
Problem: Undesired changing of the indent of the first formatted line. Solution: Do not indent the first formatted line.
Diffstat (limited to 'src/testdir/test_indent.vim')
-rw-r--r--src/testdir/test_indent.vim38
1 files changed, 32 insertions, 6 deletions
diff --git a/src/testdir/test_indent.vim b/src/testdir/test_indent.vim
index a01b066b2..f96da6969 100644
--- a/src/testdir/test_indent.vim
+++ b/src/testdir/test_indent.vim
@@ -172,7 +172,8 @@ func Test_indent_func_with_gq()
\ 'metus lectus ultrices odio, sed elementum mi ante at arcu.', '', '\begin{center}', '',
\ 'Proin nec risus consequat nunc dapibus consectetur. Mauris lacinia est a augue',
\ 'tristique accumsan. Morbi pretium, felis molestie eleifend condimentum, arcu',
- \ 'ipsum congue nisl, quis euismod purus libero in ante. Donec id semper purus.',
+ \ 'ipsum congue nisl, quis euismod purus libero in ante.', '',
+ \ 'Donec id semper purus.',
\ 'Suspendisse eget aliquam nunc. Maecenas fringilla mauris vitae maximus',
\ 'condimentum. Cras a quam in mi dictum eleifend at a lorem. Sed convallis',
\ 'ante a commodo facilisis. Nam suscipit vulputate odio, vel dapibus nisl',
@@ -181,10 +182,10 @@ func Test_indent_func_with_gq()
1d_
call cursor(5, 1)
ka
- call cursor(15, 1)
+ call cursor(14, 1)
kb
norm! 'agqap
- norm! 'bgqap
+ norm! 'bgqG
let expected = [ '\documentclass{article}', '', '\begin{document}', '',
\ 'Lorem ipsum dolor sit amet, consectetur adipiscing',
\ 'elit. Fusce ut enim non libero efficitur aliquet.',
@@ -201,9 +202,10 @@ func Test_indent_func_with_gq()
\ ' consectetur. Mauris lacinia est a augue',
\ ' tristique accumsan. Morbi pretium, felis',
\ ' molestie eleifend condimentum, arcu ipsum congue',
- \ ' nisl, quis euismod purus libero in ante. Donec',
- \ ' id semper purus. Suspendisse eget aliquam nunc.',
- \ ' Maecenas fringilla mauris vitae maximus',
+ \ ' nisl, quis euismod purus libero in ante.',
+ \ '',
+ \ ' Donec id semper purus. Suspendisse eget aliquam',
+ \ ' nunc. Maecenas fringilla mauris vitae maximus',
\ ' condimentum. Cras a quam in mi dictum eleifend',
\ ' at a lorem. Sed convallis ante a commodo',
\ ' facilisis. Nam suscipit vulputate odio, vel',
@@ -217,4 +219,28 @@ func Test_indent_func_with_gq()
delfunction GetTeXIndent
endfu
+func Test_formatting_keeps_first_line_indent()
+ let lines =<< trim END
+ foo()
+ {
+ int x; // manually positioned
+ // more text that will be formatted
+ // but not reindented
+ END
+ new
+ call setline(1, lines)
+ setlocal sw=4 cindent tw=45 et
+ normal! 4Ggqj
+ let expected =<< trim END
+ foo()
+ {
+ int x; // manually positioned
+ // more text that will be
+ // formatted but not
+ // reindented
+ END
+ call assert_equal(expected, getline(1, '$'))
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab