mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
Merge pull request #33521 from zeertzjq/vim-9.0.1653
vim-patch:9.0.{1653,1654},9.1.{0721,1317}
This commit is contained in:
@ -3099,7 +3099,7 @@ static int put_folds_recurse(FILE *fd, garray_T *gap, linenr_T off)
|
||||
if (put_folds_recurse(fd, &fp->fd_nested, off + fp->fd_top) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
if (fprintf(fd, "%" PRId64 ",%" PRId64 "fold",
|
||||
if (fprintf(fd, "sil! %" PRId64 ",%" PRId64 "fold",
|
||||
(int64_t)fp->fd_top + off,
|
||||
(int64_t)(fp->fd_top + off + fp->fd_len - 1)) < 0
|
||||
|| put_eol(fd) == FAIL) {
|
||||
@ -3121,9 +3121,10 @@ static int put_foldopen_recurse(FILE *fd, win_T *wp, garray_T *gap, linenr_T off
|
||||
if (fp->fd_flags != FD_LEVEL) {
|
||||
if (!GA_EMPTY(&fp->fd_nested)) {
|
||||
// open nested folds while this fold is open
|
||||
// ignore errors
|
||||
if (fprintf(fd, "%" PRId64, (int64_t)fp->fd_top + off) < 0
|
||||
|| put_eol(fd) == FAIL
|
||||
|| put_line(fd, "normal! zo") == FAIL) {
|
||||
|| put_line(fd, "sil! normal! zo") == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
if (put_foldopen_recurse(fd, wp, &fp->fd_nested,
|
||||
@ -3164,7 +3165,7 @@ static int put_fold_open_close(FILE *fd, fold_T *fp, linenr_T off)
|
||||
{
|
||||
if (fprintf(fd, "%" PRIdLINENR, fp->fd_top + off) < 0
|
||||
|| put_eol(fd) == FAIL
|
||||
|| fprintf(fd, "normal! z%c",
|
||||
|| fprintf(fd, "sil! normal! z%c",
|
||||
fp->fd_flags == FD_CLOSED ? 'c' : 'o') < 0
|
||||
|| put_eol(fd) == FAIL) {
|
||||
return FAIL;
|
||||
|
@ -110,6 +110,14 @@ if executable('gem')
|
||||
let $GEM_PATH = system('gem env gempath')
|
||||
endif
|
||||
|
||||
" Have current $HOME available as $ORIGHOME. $HOME is used for option
|
||||
" defaults before we get here, and test_mksession checks that.
|
||||
let $ORIGHOME = $HOME
|
||||
|
||||
if !exists('$XDG_CONFIG_HOME')
|
||||
let $XDG_CONFIG_HOME = $HOME .. '/.config'
|
||||
endif
|
||||
|
||||
" Make sure $HOME does not get read or written.
|
||||
let $HOME = expand(getcwd() . '/XfakeHOME')
|
||||
if !isdirectory($HOME)
|
||||
|
@ -1170,8 +1170,8 @@ endfunc
|
||||
|
||||
" Test for creating views with manual folds
|
||||
func Test_mkview_manual_fold()
|
||||
call writefile(range(1,10), 'Xfile')
|
||||
new Xfile
|
||||
call writefile(range(1,10), 'Xmkvfile', 'D')
|
||||
new Xmkvfile
|
||||
" create recursive folds
|
||||
5,6fold
|
||||
4,7fold
|
||||
@ -1194,9 +1194,44 @@ func Test_mkview_manual_fold()
|
||||
source Xview
|
||||
call assert_equal([-1, -1, -1, -1, -1, -1], [foldclosed(3), foldclosed(4),
|
||||
\ foldclosed(5), foldclosed(6), foldclosed(7), foldclosed(8)])
|
||||
call delete('Xfile')
|
||||
call delete('Xview')
|
||||
bw!
|
||||
endfunc
|
||||
|
||||
" Test for handling invalid folds within views
|
||||
func Test_mkview_ignore_invalid_folds()
|
||||
call writefile(range(1,10), 'Xmkvfile', 'D')
|
||||
new Xmkvfile
|
||||
" create some folds
|
||||
5,6fold
|
||||
4,7fold
|
||||
mkview Xview
|
||||
normal zE
|
||||
" delete lines to make folds invalid
|
||||
call deletebufline('', 6, '$')
|
||||
source Xview
|
||||
call assert_equal([-1, -1, -1, -1, -1, -1], [foldclosed(3), foldclosed(4),
|
||||
\ foldclosed(5), foldclosed(6), foldclosed(7), foldclosed(8)])
|
||||
call delete('Xview')
|
||||
bw!
|
||||
endfunc
|
||||
|
||||
" Test default 'viewdir' value
|
||||
func Test_mkview_default_home()
|
||||
throw 'Skipped: N/A'
|
||||
if has('win32')
|
||||
" use escape() to handle backslash path separators
|
||||
call assert_match('^' .. escape($ORIGHOME, '\') .. '/vimfiles', &viewdir)
|
||||
elseif has('unix')
|
||||
call assert_match(
|
||||
\ '^' .. $ORIGHOME .. '/.vim\|' ..
|
||||
\ '^' .. $XDG_CONFIG_HOME .. '/vim'
|
||||
\ , &viewdir)
|
||||
elseif has('amiga')
|
||||
call assert_match('^home:vimfiles', &viewdir)
|
||||
elseif has('mac')
|
||||
call assert_match('^' .. $VIM .. '/vimfiles', &viewdir)
|
||||
endif
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
Reference in New Issue
Block a user