mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 06:28:35 +00:00
vim-patch:8.0.0{469,581,583} (#8601)
vim-patch:8.0.0469: compiler warnings on MS-Windows Problem: Compiler warnings on MS-Windows. Solution: Add type casts. (Christian Brabandt)0c0d4eca4d
vim-patch:8.0.0581: moving folded text is sometimes not correct Problem: Moving folded text is sometimes not correct. Solution: Bail out when "move_end" is zero. (Matthew Malcomson)94be619e30
vim-patch:8.0.0583: fold test hangs on MS-Windows Problem: Fold test hangs on MS-Windows. Solution: Avoid overflow in compare.b11c826ddc
This commit is contained in:

committed by
Justin M. Keyes

parent
b454d24e04
commit
8794a551bd
@@ -383,12 +383,12 @@ void closeFoldRecurse(linenr_T lnum)
|
|||||||
* Used for "zo", "zO", "zc" and "zC" in Visual mode.
|
* Used for "zo", "zO", "zc" and "zC" in Visual mode.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
opFoldRange (
|
opFoldRange(
|
||||||
linenr_T first,
|
linenr_T first,
|
||||||
linenr_T last,
|
linenr_T last,
|
||||||
int opening, /* TRUE to open, FALSE to close */
|
int opening, // TRUE to open, FALSE to close
|
||||||
int recurse, /* TRUE to do it recursively */
|
int recurse, // TRUE to do it recursively
|
||||||
int had_visual /* TRUE when Visual selection used */
|
int had_visual // TRUE when Visual selection used
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int done = DONE_NOTHING; /* avoid error messages */
|
int done = DONE_NOTHING; /* avoid error messages */
|
||||||
@@ -664,11 +664,11 @@ void foldCreate(linenr_T start, linenr_T end)
|
|||||||
* When "recursive" is TRUE delete recursively.
|
* When "recursive" is TRUE delete recursively.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
deleteFold (
|
deleteFold(
|
||||||
linenr_T start,
|
linenr_T start,
|
||||||
linenr_T end,
|
linenr_T end,
|
||||||
int recursive,
|
int recursive,
|
||||||
int had_visual /* TRUE when Visual selection used */
|
int had_visual // TRUE when Visual selection used
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
garray_T *gap;
|
garray_T *gap;
|
||||||
@@ -838,9 +838,9 @@ void foldUpdateAll(win_T *win)
|
|||||||
* If not moved return FAIL.
|
* If not moved return FAIL.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
foldMoveTo (
|
foldMoveTo(
|
||||||
int updown,
|
int updown,
|
||||||
int dir, /* FORWARD or BACKWARD */
|
int dir, // FORWARD or BACKWARD
|
||||||
long count
|
long count
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -1157,10 +1157,10 @@ static void setFoldRepeat(linenr_T lnum, long count, int do_open)
|
|||||||
* Also does this for other windows in diff mode when needed.
|
* Also does this for other windows in diff mode when needed.
|
||||||
*/
|
*/
|
||||||
static linenr_T
|
static linenr_T
|
||||||
setManualFold (
|
setManualFold(
|
||||||
linenr_T lnum,
|
linenr_T lnum,
|
||||||
int opening, /* TRUE when opening, FALSE when closing */
|
int opening, // TRUE when opening, FALSE when closing
|
||||||
int recurse, /* TRUE when closing/opening recursive */
|
int recurse, // TRUE when closing/opening recursive
|
||||||
int *donep
|
int *donep
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -1195,11 +1195,11 @@ setManualFold (
|
|||||||
* It's only valid when "opening" is TRUE!
|
* It's only valid when "opening" is TRUE!
|
||||||
*/
|
*/
|
||||||
static linenr_T
|
static linenr_T
|
||||||
setManualFoldWin (
|
setManualFoldWin(
|
||||||
win_T *wp,
|
win_T *wp,
|
||||||
linenr_T lnum,
|
linenr_T lnum,
|
||||||
int opening, /* TRUE when opening, FALSE when closing */
|
int opening, // TRUE when opening, FALSE when closing
|
||||||
int recurse, /* TRUE when closing/opening recursive */
|
int recurse, // TRUE when closing/opening recursive
|
||||||
int *donep
|
int *donep
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -1506,13 +1506,13 @@ static int getDeepestNestingRecurse(garray_T *gap)
|
|||||||
* Check if a fold is closed and update the info needed to check nested folds.
|
* Check if a fold is closed and update the info needed to check nested folds.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
check_closed (
|
check_closed(
|
||||||
win_T *win,
|
win_T *win,
|
||||||
fold_T *fp,
|
fold_T *fp,
|
||||||
int *use_levelp, /* TRUE: outer fold had FD_LEVEL */
|
int *use_levelp, // TRUE: outer fold had FD_LEVEL
|
||||||
int level, /* folding depth */
|
int level, // folding depth
|
||||||
int *maybe_smallp, /* TRUE: outer this had fd_small == MAYBE */
|
int *maybe_smallp, // TRUE: outer this had fd_small == MAYBE
|
||||||
linenr_T lnum_off /* line number offset for fp->fd_top */
|
linenr_T lnum_off // line number offset for fp->fd_top
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int closed = FALSE;
|
int closed = FALSE;
|
||||||
@@ -1544,10 +1544,10 @@ check_closed (
|
|||||||
* Update fd_small field of fold "fp".
|
* Update fd_small field of fold "fp".
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
checkSmall (
|
checkSmall(
|
||||||
win_T *wp,
|
win_T *wp,
|
||||||
fold_T *fp,
|
fold_T *fp,
|
||||||
linenr_T lnum_off /* offset for fp->fd_top */
|
linenr_T lnum_off // offset for fp->fd_top
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
@@ -1652,10 +1652,10 @@ static void foldAddMarker(linenr_T lnum, const char_u *marker, size_t markerlen)
|
|||||||
* Delete the markers for a fold, causing it to be deleted.
|
* Delete the markers for a fold, causing it to be deleted.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
deleteFoldMarkers (
|
deleteFoldMarkers(
|
||||||
fold_T *fp,
|
fold_T *fp,
|
||||||
int recursive,
|
int recursive,
|
||||||
linenr_T lnum_off /* offset for fp->fd_top */
|
linenr_T lnum_off // offset for fp->fd_top
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (recursive) {
|
if (recursive) {
|
||||||
@@ -2655,9 +2655,14 @@ static void foldRemove(garray_T *gap, linenr_T top, linenr_T bot)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// foldMoveRange() {{{2
|
// foldReverseOrder() {{{2
|
||||||
static void reverse_fold_order(garray_T *gap, size_t start, size_t end)
|
static void foldReverseOrder(
|
||||||
|
garray_T *gap,
|
||||||
|
const linenr_T start_arg,
|
||||||
|
const linenr_T end_arg)
|
||||||
{
|
{
|
||||||
|
linenr_T start = start_arg;
|
||||||
|
linenr_T end = end_arg;
|
||||||
for (; start < end; start++, end--) {
|
for (; start < end; start++, end--) {
|
||||||
fold_T *left = (fold_T *)gap->ga_data + start;
|
fold_T *left = (fold_T *)gap->ga_data + start;
|
||||||
fold_T *right = (fold_T *)gap->ga_data + end;
|
fold_T *right = (fold_T *)gap->ga_data + end;
|
||||||
@@ -2667,6 +2672,7 @@ static void reverse_fold_order(garray_T *gap, size_t start, size_t end)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// foldMoveRange() {{{2
|
||||||
// Move folds within the inclusive range "line1" to "line2" to after "dest"
|
// Move folds within the inclusive range "line1" to "line2" to after "dest"
|
||||||
// require "line1" <= "line2" <= "dest"
|
// require "line1" <= "line2" <= "dest"
|
||||||
//
|
//
|
||||||
@@ -2798,9 +2804,11 @@ void foldMoveRange(garray_T *gap, const linenr_T line1, const linenr_T line2,
|
|||||||
// There are no folds after those moved, so none were moved out of order.
|
// There are no folds after those moved, so none were moved out of order.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
reverse_fold_order(gap, move_start, dest_index - 1);
|
foldReverseOrder(gap, (linenr_T)move_start, (linenr_T)(dest_index - 1));
|
||||||
reverse_fold_order(gap, move_start, move_start + dest_index - move_end - 1);
|
foldReverseOrder(gap, (linenr_T)move_start,
|
||||||
reverse_fold_order(gap, move_start + dest_index - move_end, dest_index - 1);
|
(linenr_T)(move_start + dest_index - move_end - 1));
|
||||||
|
foldReverseOrder(gap, (linenr_T)(move_start + dest_index - move_end),
|
||||||
|
(linenr_T)(dest_index - 1));
|
||||||
}
|
}
|
||||||
#undef FOLD_END
|
#undef FOLD_END
|
||||||
#undef VALID_FOLD
|
#undef VALID_FOLD
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
" Test for folding
|
" Test for folding
|
||||||
|
|
||||||
func! PrepIndent(arg)
|
func PrepIndent(arg)
|
||||||
return [a:arg] + repeat(["\t".a:arg], 5)
|
return [a:arg] + repeat(["\t".a:arg], 5)
|
||||||
endfu
|
endfu
|
||||||
|
|
||||||
func! Test_address_fold()
|
func Test_address_fold()
|
||||||
new
|
new
|
||||||
call setline(1, ['int FuncName() {/*{{{*/', 1, 2, 3, 4, 5, '}/*}}}*/',
|
call setline(1, ['int FuncName() {/*{{{*/', 1, 2, 3, 4, 5, '}/*}}}*/',
|
||||||
\ 'after fold 1', 'after fold 2', 'after fold 3'])
|
\ 'after fold 1', 'after fold 2', 'after fold 3'])
|
||||||
@@ -68,17 +68,7 @@ func! Test_address_fold()
|
|||||||
quit!
|
quit!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func! Test_indent_fold()
|
func Test_indent_fold()
|
||||||
new
|
|
||||||
call setline(1, ['', 'a', ' b', ' c'])
|
|
||||||
setl fen fdm=indent
|
|
||||||
2
|
|
||||||
norm! >>
|
|
||||||
let a=map(range(1,4), 'foldclosed(v:val)')
|
|
||||||
call assert_equal([-1,-1,-1,-1], a)
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
func! Test_indent_fold()
|
|
||||||
new
|
new
|
||||||
call setline(1, ['', 'a', ' b', ' c'])
|
call setline(1, ['', 'a', ' b', ' c'])
|
||||||
setl fen fdm=indent
|
setl fen fdm=indent
|
||||||
@@ -89,7 +79,7 @@ func! Test_indent_fold()
|
|||||||
bw!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func! Test_indent_fold2()
|
func Test_indent_fold2()
|
||||||
new
|
new
|
||||||
call setline(1, ['', '{{{', '}}}', '{{{', '}}}'])
|
call setline(1, ['', '{{{', '}}}', '{{{', '}}}'])
|
||||||
setl fen fdm=marker
|
setl fen fdm=marker
|
||||||
@@ -122,7 +112,7 @@ func Test_manual_fold_with_filter()
|
|||||||
endfor
|
endfor
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func! Test_indent_fold_with_read()
|
func Test_indent_fold_with_read()
|
||||||
new
|
new
|
||||||
set foldmethod=indent
|
set foldmethod=indent
|
||||||
call setline(1, repeat(["\<Tab>a"], 4))
|
call setline(1, repeat(["\<Tab>a"], 4))
|
||||||
@@ -224,7 +214,11 @@ func Test_update_folds_expr_read()
|
|||||||
set foldmethod& foldexpr&
|
set foldmethod& foldexpr&
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func! Test_move_folds_around_manual()
|
func Check_foldlevels(expected)
|
||||||
|
call assert_equal(a:expected, map(range(1, line('$')), 'foldlevel(v:val)'))
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_move_folds_around_manual()
|
||||||
new
|
new
|
||||||
let input = PrepIndent("a") + PrepIndent("b") + PrepIndent("c")
|
let input = PrepIndent("a") + PrepIndent("b") + PrepIndent("c")
|
||||||
call setline(1, PrepIndent("a") + PrepIndent("b") + PrepIndent("c"))
|
call setline(1, PrepIndent("a") + PrepIndent("b") + PrepIndent("c"))
|
||||||
@@ -293,11 +287,50 @@ func! Test_move_folds_around_manual()
|
|||||||
6m$
|
6m$
|
||||||
" The first fold has been truncated to the 5'th line.
|
" The first fold has been truncated to the 5'th line.
|
||||||
" Second fold has been moved up because the moved line is now below it.
|
" Second fold has been moved up because the moved line is now below it.
|
||||||
call assert_equal([0, 1, 1, 1, 1, 0, 0, 0, 1, 0], map(range(1, line('$')), 'foldlevel(v:val)'))
|
call Check_foldlevels([0, 1, 1, 1, 1, 0, 0, 0, 1, 0])
|
||||||
|
|
||||||
|
%delete
|
||||||
|
set fdm=indent foldlevel=0
|
||||||
|
call setline(1, [
|
||||||
|
\ "a",
|
||||||
|
\ "\ta",
|
||||||
|
\ "\t\ta",
|
||||||
|
\ "\t\ta",
|
||||||
|
\ "\t\ta",
|
||||||
|
\ "a",
|
||||||
|
\ "a"])
|
||||||
|
set fdm=manual
|
||||||
|
%foldopen!
|
||||||
|
4,5m6
|
||||||
|
call Check_foldlevels([0, 1, 2, 0, 0, 0, 0])
|
||||||
|
|
||||||
|
%delete
|
||||||
|
set fdm=indent
|
||||||
|
call setline(1, [
|
||||||
|
\ "\ta",
|
||||||
|
\ "\t\ta",
|
||||||
|
\ "\t\ta",
|
||||||
|
\ "\t\ta",
|
||||||
|
\ "\ta",
|
||||||
|
\ "\t\ta",
|
||||||
|
\ "\t\ta",
|
||||||
|
\ "\t\ta",
|
||||||
|
\ "\ta",
|
||||||
|
\ "\t\ta",
|
||||||
|
\ "\t\ta",
|
||||||
|
\ "\t\ta",
|
||||||
|
\ "\t\ta",
|
||||||
|
\ "\ta",
|
||||||
|
\ "a"])
|
||||||
|
set fdm=manual
|
||||||
|
%foldopen!
|
||||||
|
13m7
|
||||||
|
call Check_foldlevels([1, 2, 2, 2, 1, 2, 2, 1, 1, 1, 2, 2, 2, 1, 0])
|
||||||
|
|
||||||
bw!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func! Test_move_folds_around_indent()
|
func Test_move_folds_around_indent()
|
||||||
new
|
new
|
||||||
let input = PrepIndent("a") + PrepIndent("b") + PrepIndent("c")
|
let input = PrepIndent("a") + PrepIndent("b") + PrepIndent("c")
|
||||||
call setline(1, PrepIndent("a") + PrepIndent("b") + PrepIndent("c"))
|
call setline(1, PrepIndent("a") + PrepIndent("b") + PrepIndent("c"))
|
||||||
@@ -357,7 +390,7 @@ func! Test_move_folds_around_indent()
|
|||||||
6m$
|
6m$
|
||||||
" The first fold has been truncated to the 5'th line.
|
" The first fold has been truncated to the 5'th line.
|
||||||
" Second fold has been moved up because the moved line is now below it.
|
" Second fold has been moved up because the moved line is now below it.
|
||||||
call assert_equal([0, 1, 1, 1, 1, 0, 0, 0, 1, 1], map(range(1, line('$')), 'foldlevel(v:val)'))
|
call Check_foldlevels([0, 1, 1, 1, 1, 0, 0, 0, 1, 1])
|
||||||
bw!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user