mirror of
https://github.com/neovim/neovim.git
synced 2026-02-20 01:09:56 +10:00
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:
@@ -1707,9 +1707,9 @@ func Test_cindent_1()
|
||||
#endif
|
||||
|
||||
int y; // comment
|
||||
// comment
|
||||
// comment
|
||||
|
||||
// comment
|
||||
// comment
|
||||
|
||||
{
|
||||
Constructor(int a,
|
||||
|
||||
@@ -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!
|
||||
|
||||
Reference in New Issue
Block a user