Merge pull request #17254 from zeertzjq/vim-8.2.3787

vim-patch:8.2.{3787,3932,3934,3935,3938}: text formatting patches
This commit is contained in:
zeertzjq
2022-02-01 04:23:59 +08:00
committed by GitHub
9 changed files with 286 additions and 4901 deletions

View File

@@ -1707,9 +1707,9 @@ func Test_cindent_1()
#endif
int y; // comment
// comment
// comment
// comment
// comment
{
Constructor(int a,

View File

@@ -196,6 +196,104 @@ func Test_text_format()
enew!
endfunc
func Test_format_c_comment()
new
setl ai cindent tw=40 et fo=croql
let text =<< trim END
var = 2345; // asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf
END
call setline(1, text)
normal gql
let expected =<< trim END
var = 2345; // asdf asdf asdf asdf asdf
// asdf asdf asdf asdf asdf
END
call assert_equal(expected, getline(1, '$'))
%del
let text =<< trim END
var = 2345; // asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf
END
call setline(1, text)
normal gql
let expected =<< trim END
var = 2345; // asdf asdf asdf asdf asdf
// asdf asdf asdf asdf asdf
// asdf asdf
END
call assert_equal(expected, getline(1, '$'))
%del
let text =<< trim END
#if 0 // This is another long end of
// line comment that
// wraps.
END
call setline(1, text)
normal gq2j
let expected =<< trim END
#if 0 // This is another long
// end of line comment
// that wraps.
END
call assert_equal(expected, getline(1, '$'))
" Using "o" repeats the line comment, "O" does not.
%del
let text =<< trim END
nop;
val = val; // This is a comment
END
call setline(1, text)
normal 2Go
let expected =<< trim END
nop;
val = val; // This is a comment
//
END
call assert_equal(expected, getline(1, '$'))
normal 2GO
let expected =<< trim END
nop;
val = val; // This is a comment
//
END
call assert_equal(expected, getline(1, '$'))
" Using "o" does not repeat a comment in a string
%del
let text =<< trim END
nop;
val = " // This is not a comment";
END
call setline(1, text)
normal 2Gox
let expected =<< trim END
nop;
val = " // This is not a comment";
x
END
call assert_equal(expected, getline(1, '$'))
" Using CTRL-U after "o" fixes the indent
%del
let text =<< trim END
{
val = val; // This is a comment
END
call setline(1, text)
exe "normal! 2Go\<C-U>x\<Esc>"
let expected =<< trim END
{
val = val; // This is a comment
x
END
call assert_equal(expected, getline(1, '$'))
bwipe!
endfunc
" Tests for :right, :center and :left on text with embedded TAB.
func Test_format_align()
enew!