From 3ab6a519fca63d1fcb5eeb98437697a7abaca7b0 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Sun, 24 Sep 2017 09:29:08 +0800 Subject: vim-patch:8.0.0328 Problem: The "zero count" error doesn't have a number. (Hirohito Higashi) Solution: Give it a number and be more specific about the error. https://github.com/vim/vim/commit/23a5558cfd860401aa694f0302d621887440f031 --- src/nvim/globals.h | 5 +++-- src/nvim/version.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 2ee72cdb6a..300e506854 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -1146,8 +1146,9 @@ EXTERN char_u e_winheight[] INIT(= N_( EXTERN char_u e_winwidth[] INIT(= N_( "E592: 'winwidth' cannot be smaller than 'winminwidth'")); EXTERN char_u e_write[] INIT(= N_("E80: Error while writing")); -EXTERN char_u e_zerocount[] INIT(= N_("Zero count")); -EXTERN char_u e_usingsid[] INIT(= N_("E81: Using not in a script context")); +EXTERN char_u e_zerocount[] INIT(= N_("E939: Positive count required")); +EXTERN char_u e_usingsid[] INIT(= N_( + "E81: Using not in a script context")); EXTERN char_u e_intern2[] INIT(= N_("E685: Internal error: %s")); EXTERN char_u e_maxmempat[] INIT(= N_( "E363: pattern uses more memory than 'maxmempattern'")); diff --git a/src/nvim/version.c b/src/nvim/version.c index d4f9c0232f..09a62a3b0e 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -624,7 +624,7 @@ static const int included_patches[] = { 331, // 330, // 329, - // 328, + 328, 327, 326, 325, -- cgit From 006425b8b683711cfb4f89074034ec1fe2085d40 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Sun, 24 Sep 2017 09:48:52 +0800 Subject: vim-patch:8.0.0330 Problem: Illegal memory access after "vapo". (Dominique Pelle) Solution: Fix the cursor column. https://github.com/vim/vim/commit/84b2a381451e9068b09ef6d85f5e8cf1598e7355 --- src/nvim/search.c | 12 ++++++++---- src/nvim/testdir/test_visual.vim | 7 +++++++ src/nvim/version.c | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/search.c b/src/nvim/search.c index 1bf2317d2a..387614fd09 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -3557,11 +3557,15 @@ extend: --start_lnum; if (VIsual_active) { - /* Problem: when doing "Vipipip" nothing happens in a single white - * line, we get stuck there. Trap this here. */ - if (VIsual_mode == 'V' && start_lnum == curwin->w_cursor.lnum) + // Problem: when doing "Vipipip" nothing happens in a single white + // line, we get stuck there. Trap this here. + if (VIsual_mode == 'V' && start_lnum == curwin->w_cursor.lnum) { goto extend; - VIsual.lnum = start_lnum; + } + if (VIsual.lnum != start_lnum) { + VIsual.lnum = start_lnum; + VIsual.col = 0; + } VIsual_mode = 'V'; redraw_curbuf_later(INVERTED); /* update the inversion */ showmode(); diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index 74c26e3d66..8cb59ca32a 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -28,3 +28,10 @@ func Test_Visual_ctrl_o() set tw& bw! endfu + +func Test_Visual_vapo() + new + normal oxx + normal vapo + bwipe! +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index d4f9c0232f..b642777d8a 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -622,7 +622,7 @@ static const int included_patches[] = { // 333, // 332, 331, - // 330, + 330, // 329, // 328, 327, -- cgit From 2b53a565b991fc329ab7af683ec50e9cfcac557f Mon Sep 17 00:00:00 2001 From: ckelsel Date: Sun, 24 Sep 2017 10:05:53 +0800 Subject: vim-patch:8.0.0333 Problem: Illegal memory access when 'complete' ends in a backslash. Solution: Check for trailing backslash. (Dominique Pelle, closes vim/vim#1478) https://github.com/vim/vim/commit/226c53429109f24e31c17016aedfd7fbf7a9aa50 --- src/nvim/option.c | 7 ++++--- src/nvim/testdir/test_options.vim | 10 ++++++++++ src/nvim/version.c | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/option.c b/src/nvim/option.c index 74250e83e6..13aadb71bb 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -2997,9 +2997,10 @@ did_set_string_option ( if (s[-1] == 'k' || s[-1] == 's') { /* skip optional filename after 'k' and 's' */ while (*s && *s != ',' && *s != ' ') { - if (*s == '\\') - ++s; - ++s; + if (*s == '\\' && s[1] != NUL) { + s++; + } + s++; } } else { if (errbuf != NULL) { diff --git a/src/nvim/testdir/test_options.vim b/src/nvim/testdir/test_options.vim index 2ffe63787b..8a9d793a2e 100644 --- a/src/nvim/testdir/test_options.vim +++ b/src/nvim/testdir/test_options.vim @@ -103,3 +103,13 @@ func Test_keymap_valid() call assert_fails(":set kmp=trunc\x00name", "E544:") call assert_fails(":set kmp=trunc\x00name", "trunc") endfunc + +func Test_complete() + " Trailing single backslash used to cause invalid memory access. + set complete=s\ + new + call feedkeys("i\\", 'xt') + bwipe! + set complete& +endfun + diff --git a/src/nvim/version.c b/src/nvim/version.c index d4f9c0232f..7470b07655 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -619,7 +619,7 @@ static const int included_patches[] = { // 336, // 335, // 334, - // 333, + 333, // 332, 331, // 330, -- cgit From 2b4a52f901bf4cc9a88c45eea39c303028091dd3 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Sun, 24 Sep 2017 23:20:45 +0800 Subject: vim-patch:8.0.0091 (#7312) Problem: Test_help_complete sometimes fails in MS-Windows console. Solution: Use getcompletion() instead of feedkeys() and command line completion. (Hirohito Higashi) https://github.com/vim/vim/commit/9f0e423c2818c0cacd0810f9c3c67cbb6b80963d --- src/nvim/testdir/test_help_tagjump.vim | 57 ++++++++++++++-------------------- src/nvim/version.c | 2 +- 2 files changed, 25 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_help_tagjump.vim b/src/nvim/testdir/test_help_tagjump.vim index 1ca0f722cf..65d99c644c 100644 --- a/src/nvim/testdir/test_help_tagjump.vim +++ b/src/nvim/testdir/test_help_tagjump.vim @@ -89,17 +89,8 @@ func s:doc_config_teardown() endif endfunc -func s:get_cmd_compl_list(cmd) - let list = [] - let str = '' - for cnt in range(1, 999) - call feedkeys(a:cmd . repeat("\", cnt) . "'\let str='\", 'tx') - if str ==# a:cmd[1:] - break - endif - call add(list, str) - endfor - return list +func s:get_help_compl_list(cmd) + return getcompletion(a:cmd, 'help') endfunc func Test_help_complete() @@ -111,49 +102,49 @@ func Test_help_complete() if has('multi_lang') set helplang= endif - let list = s:get_cmd_compl_list(":h test") - call assert_equal(['h test-col', 'h test-char'], list) + let list = s:get_help_compl_list("test") + call assert_equal(['test-col', 'test-char'], list) if has('multi_lang') " 'helplang=ab' and help file lang is 'en' set helplang=ab - let list = s:get_cmd_compl_list(":h test") - call assert_equal(['h test-col', 'h test-char'], list) + let list = s:get_help_compl_list("test") + call assert_equal(['test-col', 'test-char'], list) " 'helplang=' and help file lang is 'en' and 'ab' set rtp+=Xdir1/doc-ab set helplang= - let list = s:get_cmd_compl_list(":h test") - call assert_equal(sort(['h test-col@en', 'h test-col@ab', - \ 'h test-char@en', 'h test-char@ab']), sort(list)) + let list = s:get_help_compl_list("test") + call assert_equal(sort(['test-col@en', 'test-col@ab', + \ 'test-char@en', 'test-char@ab']), sort(list)) " 'helplang=ab' and help file lang is 'en' and 'ab' set helplang=ab - let list = s:get_cmd_compl_list(":h test") - call assert_equal(sort(['h test-col', 'h test-col@en', - \ 'h test-char', 'h test-char@en']), sort(list)) + let list = s:get_help_compl_list("test") + call assert_equal(sort(['test-col', 'test-col@en', + \ 'test-char', 'test-char@en']), sort(list)) " 'helplang=' and help file lang is 'en', 'ab' and 'ja' set rtp+=Xdir1/doc-ja set helplang= - let list = s:get_cmd_compl_list(":h test") - call assert_equal(sort(['h test-col@en', 'h test-col@ab', - \ 'h test-col@ja', 'h test-char@en', - \ 'h test-char@ab', 'h test-char@ja']), sort(list)) + let list = s:get_help_compl_list("test") + call assert_equal(sort(['test-col@en', 'test-col@ab', + \ 'test-col@ja', 'test-char@en', + \ 'test-char@ab', 'test-char@ja']), sort(list)) " 'helplang=ab' and help file lang is 'en', 'ab' and 'ja' set helplang=ab - let list = s:get_cmd_compl_list(":h test") - call assert_equal(sort(['h test-col', 'h test-col@en', - \ 'h test-col@ja', 'h test-char', - \ 'h test-char@en', 'h test-char@ja']), sort(list)) + let list = s:get_help_compl_list("test") + call assert_equal(sort(['test-col', 'test-col@en', + \ 'test-col@ja', 'test-char', + \ 'test-char@en', 'test-char@ja']), sort(list)) " 'helplang=ab,ja' and help file lang is 'en', 'ab' and 'ja' set helplang=ab,ja - let list = s:get_cmd_compl_list(":h test") - call assert_equal(sort(['h test-col', 'h test-col@ja', - \ 'h test-col@en', 'h test-char', - \ 'h test-char@ja', 'h test-char@en']), sort(list)) + let list = s:get_help_compl_list("test") + call assert_equal(sort(['test-col', 'test-col@ja', + \ 'test-col@en', 'test-char', + \ 'test-char@ja', 'test-char@en']), sort(list)) endif catch call assert_exception('X') diff --git a/src/nvim/version.c b/src/nvim/version.c index d4f9c0232f..16523380cc 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -861,7 +861,7 @@ static const int included_patches[] = { // 94 NA // 93 NA 92, - // 91, + 91, 90, // 89 NA 88, -- cgit From 1c7f396f0cba3e87c4c1cae041489e28d59d1306 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 26 Sep 2017 15:32:31 -0400 Subject: vim-patch:8.0.0112 Problem: Tests 92 and 93 are old style. Solution: Make test92 and test93 new style. (Hirohito Higashi, closes vim/vim#1289) https://github.com/vim/vim/commit/eca626fcdb73d480660c78b9f84cc043fa561922 --- src/nvim/testdir/test_mksession.vim | 102 +++++++++++++++++++++++++++++- src/nvim/testdir/test_mksession_utf8.vim | 104 +++++++++++++++++++++++++++++++ src/nvim/version.c | 2 +- 3 files changed, 206 insertions(+), 2 deletions(-) create mode 100644 src/nvim/testdir/test_mksession_utf8.vim (limited to 'src') diff --git a/src/nvim/testdir/test_mksession.vim b/src/nvim/testdir/test_mksession.vim index 2238213850..928f065efb 100644 --- a/src/nvim/testdir/test_mksession.vim +++ b/src/nvim/testdir/test_mksession.vim @@ -1,4 +1,104 @@ -" Tests for sessions +" Test for :mksession, :mkview and :loadview in latin1 encoding + +scriptencoding latin1 + +if !has('multi_byte') || !has('mksession') + finish +endif + +func Test_mksession() + tabnew + let wrap_save = &wrap + set sessionoptions=buffers splitbelow fileencoding=latin1 + call setline(1, [ + \ 'start:', + \ 'no multibyte chAracter', + \ ' one leaDing tab', + \ ' four leadinG spaces', + \ 'two consecutive tabs', + \ 'two tabs in one line', + \ 'one multibyteCharacter', + \ 'a two multiByte characters', + \ 'A three mulTibyte characters' + \ ]) + let tmpfile = tempname() + exec 'w! ' . tmpfile + /^start: + set wrap + vsplit + norm! j16| + split + norm! j16| + split + norm! j16| + split + norm! j8| + split + norm! j8| + split + norm! j16| + split + norm! j16| + split + norm! j16| + wincmd l + + set nowrap + /^start: + norm! j16|3zl + split + norm! j016|3zl + split + norm! j016|3zl + split + norm! j08|3zl + split + norm! j08|3zl + split + norm! j016|3zl + split + norm! j016|3zl + split + norm! j016|3zl + split + call wincol() + mksession! test_mks.out + let li = filter(readfile('test_mks.out'), 'v:val =~# "\\(^ *normal! 0\\|^ *exe ''normal!\\)"') + let expected = [ + \ 'normal! 016|', + \ 'normal! 016|', + \ 'normal! 016|', + \ 'normal! 08|', + \ 'normal! 08|', + \ 'normal! 016|', + \ 'normal! 016|', + \ 'normal! 016|', + \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'", + \ " normal! 016|", + \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'", + \ " normal! 016|", + \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'", + \ " normal! 016|", + \ " exe 'normal! ' . s:c . '|zs' . 8 . '|'", + \ " normal! 08|", + \ " exe 'normal! ' . s:c . '|zs' . 8 . '|'", + \ " normal! 08|", + \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'", + \ " normal! 016|", + \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'", + \ " normal! 016|", + \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'", + \ " normal! 016|", + \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'", + \ " normal! 016|" + \ ] + call assert_equal(expected, li) + tabclose! + + call delete('test_mks.out') + call delete(tmpfile) + let &wrap = wrap_save +endfunc " Verify that arglist is stored correctly to the session file. func Test_mksession_arglist() diff --git a/src/nvim/testdir/test_mksession_utf8.vim b/src/nvim/testdir/test_mksession_utf8.vim new file mode 100644 index 0000000000..c05a1d3b6d --- /dev/null +++ b/src/nvim/testdir/test_mksession_utf8.vim @@ -0,0 +1,104 @@ +" Test for :mksession, :mkview and :loadview in utf-8 encoding + +set encoding=utf-8 +scriptencoding utf-8 + +if !has('multi_byte') || !has('mksession') + finish +endif + +func Test_mksession_utf8() + tabnew + let wrap_save = &wrap + set sessionoptions=buffers splitbelow fileencoding=utf-8 + call setline(1, [ + \ 'start:', + \ 'no multibyte chAracter', + \ ' one leaDing tab', + \ ' four leadinG spaces', + \ 'two consecutive tabs', + \ 'two tabs in one line', + \ 'one … multibyteCharacter', + \ 'a “b” two multiByte characters', + \ '“c”1€ three mulTibyte characters' + \ ]) + let tmpfile = tempname() + exec 'w! ' . tmpfile + /^start: + set wrap + vsplit + norm! j16| + split + norm! j16| + split + norm! j16| + split + norm! j8| + split + norm! j8| + split + norm! j16| + split + norm! j16| + split + norm! j16| + wincmd l + + set nowrap + /^start: + norm! j16|3zl + split + norm! j016|3zl + split + norm! j016|3zl + split + norm! j08|3zl + split + norm! j08|3zl + split + norm! j016|3zl + split + norm! j016|3zl + split + norm! j016|3zl + split + call wincol() + mksession! test_mks.out + let li = filter(readfile('test_mks.out'), 'v:val =~# "\\(^ *normal! 0\\|^ *exe ''normal!\\)"') + let expected = [ + \ 'normal! 016|', + \ 'normal! 016|', + \ 'normal! 016|', + \ 'normal! 08|', + \ 'normal! 08|', + \ 'normal! 016|', + \ 'normal! 016|', + \ 'normal! 016|', + \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'", + \ " normal! 016|", + \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'", + \ " normal! 016|", + \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'", + \ " normal! 016|", + \ " exe 'normal! ' . s:c . '|zs' . 8 . '|'", + \ " normal! 08|", + \ " exe 'normal! ' . s:c . '|zs' . 8 . '|'", + \ " normal! 08|", + \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'", + \ " normal! 016|", + \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'", + \ " normal! 016|", + \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'", + \ " normal! 016|", + \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'", + \ " normal! 016|" + \ ] + call assert_equal(expected, li) + tabclose! + + call delete('test_mks.out') + call delete(tmpfile) + let &wrap = wrap_save +endfunc + +" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/version.c b/src/nvim/version.c index a060b4a74f..80018f6eab 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -840,7 +840,7 @@ static const int included_patches[] = { // 115 NA // 114 NA // 113 NA - // 112, + 112, 111, 110, // 109 NA -- cgit From 5bb2a19417e33ef573411b2069ab3d8095f7a9fa Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 26 Sep 2017 15:39:41 -0400 Subject: vim-patch:8.0.0253 Problem: When creating a session when winminheight is 2 or larger and loading that session gives an error. Solution: Also set winminheight before setting winheight to 1. (Rafael Bodill, neovim vim/vim#5717) https://github.com/vim/vim/commit/36ae89c550a4f0a380606c3fb4a054957ad698f0 --- src/nvim/ex_docmd.c | 2 ++ src/nvim/testdir/test_mksession.vim | 9 +++++++++ src/nvim/version.c | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 47e23b6e80..5145c65bc7 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -8933,6 +8933,8 @@ makeopens ( // resized when moving between windows. // Do this before restoring the view, so that the topline and the // cursor can be set. This is done again below. + // winminheight and winminwidth need to be set to avoid an error if the + // user has set winheight or winwidth. if (put_line(fd, "set winminheight=1 winminwidth=1 winheight=1 winwidth=1") == FAIL) { return FAIL; diff --git a/src/nvim/testdir/test_mksession.vim b/src/nvim/testdir/test_mksession.vim index 928f065efb..284bafab75 100644 --- a/src/nvim/testdir/test_mksession.vim +++ b/src/nvim/testdir/test_mksession.vim @@ -100,6 +100,15 @@ func Test_mksession() let &wrap = wrap_save endfunc +func Test_mksession_winheight() + new + set winheight=10 winminheight=2 + mksession! test_mks.out + source test_mks.out + + " call delete('test_mks.out') +endfunc + " Verify that arglist is stored correctly to the session file. func Test_mksession_arglist() argdel * diff --git a/src/nvim/version.c b/src/nvim/version.c index 80018f6eab..f2686eacec 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -699,7 +699,7 @@ static const int included_patches[] = { // 256, // 255, // 254, - // 253, + 253, // 252, // 251, 250, -- cgit From 43da7ea27b3391a9e74c658b90a5ed1cae926d40 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 26 Sep 2017 15:50:09 -0400 Subject: vim-patch:8.0.0258 Problem: mksession test leaves file behind. Solution: Delete the file. Rename files to start with "X". https://github.com/vim/vim/commit/c9b56b2ceb4662f87c39ea07ba5090a073fd6286 --- src/nvim/testdir/test_mksession.vim | 14 +++++++------- src/nvim/version.c | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_mksession.vim b/src/nvim/testdir/test_mksession.vim index 284bafab75..7158b31a14 100644 --- a/src/nvim/testdir/test_mksession.vim +++ b/src/nvim/testdir/test_mksession.vim @@ -21,7 +21,7 @@ func Test_mksession() \ 'a two multiByte characters', \ 'A three mulTibyte characters' \ ]) - let tmpfile = tempname() + let tmpfile = 'Xtemp' exec 'w! ' . tmpfile /^start: set wrap @@ -62,8 +62,8 @@ func Test_mksession() norm! j016|3zl split call wincol() - mksession! test_mks.out - let li = filter(readfile('test_mks.out'), 'v:val =~# "\\(^ *normal! 0\\|^ *exe ''normal!\\)"') + mksession! Xtest_mks.out + let li = filter(readfile('Xtest_mks.out'), 'v:val =~# "\\(^ *normal! 0\\|^ *exe ''normal!\\)"') let expected = [ \ 'normal! 016|', \ 'normal! 016|', @@ -95,7 +95,7 @@ func Test_mksession() call assert_equal(expected, li) tabclose! - call delete('test_mks.out') + call delete('Xtest_mks.out') call delete(tmpfile) let &wrap = wrap_save endfunc @@ -103,10 +103,10 @@ endfunc func Test_mksession_winheight() new set winheight=10 winminheight=2 - mksession! test_mks.out - source test_mks.out + mksession! Xtest_mks.out + source Xtest_mks.out - " call delete('test_mks.out') + call delete('Xtest_mks.out') endfunc " Verify that arglist is stored correctly to the session file. diff --git a/src/nvim/version.c b/src/nvim/version.c index f2686eacec..580ed592ca 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -694,7 +694,7 @@ static const int included_patches[] = { // 261, // 260 NA 259, - // 258, + 258, // 257 NA // 256, // 255, -- cgit From 25d4cd7e2830265505b0f6f88e6d08b4954af6eb Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 26 Sep 2017 15:52:21 -0400 Subject: vim-patch:8.0.1024 Problem: Manual folds are lost when a session file has the same buffer in two windows. (Jeansen) Solution: Use ":edit" only once. (Christian Brabandt, closes vim/vim#1958) https://github.com/vim/vim/commit/4bebc9a0565670b853d227f81a9a31eafdb47eed --- src/nvim/ex_docmd.c | 43 ++++++---- src/nvim/testdir/test_mksession.vim | 32 ++++++++ src/nvim/version.c | 151 ++++++++++++++++++++++++++++++++++++ 3 files changed, 209 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 5145c65bc7..87d9e10619 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -8813,7 +8813,7 @@ makeopens ( buf->b_wininfo == NULL ? (int64_t)1L : (int64_t)buf->b_wininfo->wi_fpos.lnum) < 0 - || ses_fname(fd, buf, &ssop_flags) == FAIL) + || ses_fname(fd, buf, &ssop_flags, true) == FAIL) return FAIL; } } @@ -8885,7 +8885,7 @@ makeopens ( && !bt_nofile(wp->w_buffer) ) { if (fputs(need_tabnew ? "tabedit " : "edit ", fd) < 0 - || ses_fname(fd, wp->w_buffer, &ssop_flags) == FAIL) + || ses_fname(fd, wp->w_buffer, &ssop_flags, true) == FAIL) return FAIL; need_tabnew = FALSE; if (!wp->w_arg_idx_invalid) @@ -9223,21 +9223,30 @@ put_view ( if (wp->w_buffer->b_ffname != NULL && (!bt_nofile(wp->w_buffer) || wp->w_buffer->terminal) ) { - /* - * Editing a file in this buffer: use ":edit file". - * This may have side effects! (e.g., compressed or network file). - */ - if (fputs("edit ", fd) < 0 - || ses_fname(fd, wp->w_buffer, flagp) == FAIL) + // Editing a file in this buffer: use ":edit file". + // This may have side effects! (e.g., compressed or network file). + // + // Note, if a buffer for that file already exists, use :badd to + // edit that buffer, to not lose folding information (:edit resets + // folds in other buffers) + if (fputs("if bufexists('", fd) < 0 + || ses_fname(fd, wp->w_buffer, flagp, false) == FAIL + || fputs("') | buffer ", fd) < 0 + || ses_fname(fd, wp->w_buffer, flagp, false) == FAIL + || fputs(" | else | edit ", fd) < 0 + || ses_fname(fd, wp->w_buffer, flagp, false) == FAIL + || fputs(" | endif", fd) < 0 + || put_eol(fd) == FAIL) { return FAIL; + } } else { /* No file in this buffer, just make it empty. */ if (put_line(fd, "enew") == FAIL) return FAIL; if (wp->w_buffer->b_ffname != NULL) { - /* The buffer does have a name, but it's not a file name. */ + // The buffer does have a name, but it's not a file name. if (fputs("file ", fd) < 0 - || ses_fname(fd, wp->w_buffer, flagp) == FAIL) + || ses_fname(fd, wp->w_buffer, flagp, true) == FAIL) return FAIL; } do_cursor = FALSE; @@ -9391,12 +9400,10 @@ ses_arglist ( return OK; } -/* - * Write a buffer name to the session file. - * Also ends the line. - * Returns FAIL if writing fails. - */ -static int ses_fname(FILE *fd, buf_T *buf, unsigned *flagp) +/// Write a buffer name to the session file. +/// Also ends the line, if "add_eol" is true. +/// Returns FAIL if writing fails. +static int ses_fname(FILE *fd, buf_T *buf, unsigned *flagp, bool add_eol) { char_u *name; @@ -9413,8 +9420,10 @@ static int ses_fname(FILE *fd, buf_T *buf, unsigned *flagp) name = buf->b_sfname; else name = buf->b_ffname; - if (ses_put_fname(fd, name, flagp) == FAIL || put_eol(fd) == FAIL) + if (ses_put_fname(fd, name, flagp) == FAIL + || (add_eol && put_eol(fd) == FAIL)) { return FAIL; + } return OK; } diff --git a/src/nvim/testdir/test_mksession.vim b/src/nvim/testdir/test_mksession.vim index 7158b31a14..13fb07c7e0 100644 --- a/src/nvim/testdir/test_mksession.vim +++ b/src/nvim/testdir/test_mksession.vim @@ -121,4 +121,36 @@ func Test_mksession_arglist() argdel * endfunc + +func Test_mksession_one_buffer_two_windows() + edit Xtest1 + new Xtest2 + split + mksession! Xtest_mks.out + let lines = readfile('Xtest_mks.out') + let count1 = 0 + let count2 = 0 + let count2buf = 0 + for line in lines + if line =~ 'edit \f*Xtest1$' + let count1 += 1 + endif + if line =~ 'edit \f\{-}Xtest2' + let count2 += 1 + endif + if line =~ 'buffer \f\{-}Xtest2' + let count2buf += 1 + endif + endfor + call assert_equal(1, count1, 'Xtest1 count') + call assert_equal(2, count2, 'Xtest2 count') + call assert_equal(2, count2buf, 'Xtest2 buffer count') + + close + bwipe! + !cp Xtest_mks.out /tmp + call delete('Xtest_mks.out') +endfunc + + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/version.c b/src/nvim/version.c index 580ed592ca..9f75f75d4f 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -77,6 +77,157 @@ static char *features[] = { // clang-format off static const int included_patches[] = { + // 1026, + // 1025, + 1024, + // 1023, + // 1022, + // 1021, + // 1020, + // 1019, + // 1018, + // 1017, + // 1016, + // 1015, + // 1014, + // 1013, + // 1012, + // 1011, + // 1010, + // 1009, + // 1008, + // 1007, + // 1006, + // 1005, + // 1004, + // 1003, + // 1002, + // 1001, + // 1000, + // 999, + // 998, + // 997, + // 996, + // 995, + // 994, + // 993, + // 992, + // 991, + // 990, + // 989, + // 988, + // 987, + // 986, + // 985, + // 984, + // 983, + // 982, + // 981, + // 980, + // 979, + // 978, + // 977, + // 976, + // 975, + // 974, + // 973, + // 972, + // 971, + // 970, + // 969, + // 968, + // 967, + // 966, + // 965, + // 964, + // 963, + // 962, + // 961, + // 960, + // 959, + // 958, + // 957, + // 956, + // 955, + // 954, + // 953, + // 952, + // 951, + // 950, + // 949, + // 948, + // 947, + // 946, + // 945, + // 944, + // 943, + // 942, + // 941, + // 940, + // 939, + // 938, + // 937, + // 936, + // 935, + // 934, + // 933, + // 932, + // 931, + // 930, + // 929, + // 928, + // 927, + // 926, + // 925, + // 924, + // 923, + // 922, + // 921, + // 920, + // 919, + // 918, + // 917, + // 916, + // 915, + // 914, + // 913, + // 912, + // 911, + // 910, + // 909, + // 908, + // 907, + // 906, + // 905, + // 904, + // 903, + // 902, + // 901, + // 900, + // 899, + // 898, + // 897, + // 896, + // 895, + // 894, + // 893, + // 892, + // 891, + // 890, + // 889, + // 888, + // 887, + // 886, + // 885, + // 884, + // 883, + // 882, + // 881, + // 880, + // 879, + // 878, + // 877, + // 876, // 875, // 874, // 873, -- cgit From e0197a4d76420e611e9da2f437f01cb31d65cdb0 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 26 Sep 2017 16:04:01 -0400 Subject: vim-patch:8.0.1025 Problem: Stray copy command in test. Solution: Remove the copy command. https://github.com/vim/vim/commit/4e83961985abb78757b135f29ac4ffde675247af --- src/nvim/testdir/test_mksession.vim | 1 - src/nvim/version.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_mksession.vim b/src/nvim/testdir/test_mksession.vim index 13fb07c7e0..4774cf4af5 100644 --- a/src/nvim/testdir/test_mksession.vim +++ b/src/nvim/testdir/test_mksession.vim @@ -148,7 +148,6 @@ func Test_mksession_one_buffer_two_windows() close bwipe! - !cp Xtest_mks.out /tmp call delete('Xtest_mks.out') endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index 9f75f75d4f..fa8b495703 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -78,7 +78,7 @@ static char *features[] = { // clang-format off static const int included_patches[] = { // 1026, - // 1025, + 1025, 1024, // 1023, // 1022, -- cgit From f66307475db14858310f103600b42f23ff7ce48e Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 26 Sep 2017 16:08:15 -0400 Subject: lint --- src/nvim/ex_docmd.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 87d9e10619..3130747e08 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -8810,11 +8810,12 @@ makeopens ( && buf->b_fname != NULL && buf->b_p_bl) { if (fprintf(fd, "badd +%" PRId64 " ", - buf->b_wininfo == NULL ? - (int64_t)1L : - (int64_t)buf->b_wininfo->wi_fpos.lnum) < 0 - || ses_fname(fd, buf, &ssop_flags, true) == FAIL) + buf->b_wininfo == NULL + ? (int64_t)1L + : (int64_t)buf->b_wininfo->wi_fpos.lnum) < 0 + || ses_fname(fd, buf, &ssop_flags, true) == FAIL) { return FAIL; + } } } @@ -8885,11 +8886,13 @@ makeopens ( && !bt_nofile(wp->w_buffer) ) { if (fputs(need_tabnew ? "tabedit " : "edit ", fd) < 0 - || ses_fname(fd, wp->w_buffer, &ssop_flags, true) == FAIL) + || ses_fname(fd, wp->w_buffer, &ssop_flags, true) == FAIL) { return FAIL; - need_tabnew = FALSE; - if (!wp->w_arg_idx_invalid) + } + need_tabnew = false; + if (!wp->w_arg_idx_invalid) { edited_win = wp; + } break; } } @@ -9240,16 +9243,18 @@ put_view ( return FAIL; } } else { - /* No file in this buffer, just make it empty. */ - if (put_line(fd, "enew") == FAIL) + // No file in this buffer, just make it empty. + if (put_line(fd, "enew") == FAIL) { return FAIL; + } if (wp->w_buffer->b_ffname != NULL) { // The buffer does have a name, but it's not a file name. if (fputs("file ", fd) < 0 - || ses_fname(fd, wp->w_buffer, flagp, true) == FAIL) + || ses_fname(fd, wp->w_buffer, flagp, true) == FAIL) { return FAIL; + } } - do_cursor = FALSE; + do_cursor = false; } } -- cgit