mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
vim-patch:9.1.1317: noisy error when restoring folds from session fails
Problem: noisy error when restoring folds from session fails
Solution: ignore errors silently when sourcing session file.
(Igor Lacerda)
fixes: vim/vim#15813
closes: vim/vim#17127
cca5dea76e
Co-authored-by: Igor Lacerda <igorlfs@ufmg.br>
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;
|
||||
|
@ -1198,6 +1198,24 @@ func Test_mkview_manual_fold()
|
||||
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'
|
||||
|
Reference in New Issue
Block a user