diff options
-rw-r--r-- | runtime/autoload/tutor.vim | 7 | ||||
-rw-r--r-- | runtime/doc/options.txt | 6 | ||||
-rw-r--r-- | runtime/ftplugin/tutor.vim | 3 | ||||
-rw-r--r-- | runtime/tutor/en/vim-01-beginner.tutor | 10 | ||||
-rw-r--r-- | src/nvim/shada.c | 9 | ||||
-rw-r--r-- | test/functional/shada/buffers_spec.lua | 43 |
6 files changed, 67 insertions, 11 deletions
diff --git a/runtime/autoload/tutor.vim b/runtime/autoload/tutor.vim index d2881f7f34..5182c53f35 100644 --- a/runtime/autoload/tutor.vim +++ b/runtime/autoload/tutor.vim @@ -2,6 +2,12 @@ " Setup: {{{1 function! tutor#SetupVim() + if &col < 90 + set columns=90 + endif + if !exists('g:did_load_ftplugin') || g:did_load_ftplugin != 1 + filetype plugin on + endif if has('syntax') if !exists('g:syntax_on') || g:syntax_on == 0 syntax on @@ -336,6 +342,7 @@ function! tutor#TutorCmd(tutor_name) let l:to_open = l:tutors[l:tutor_to_open-1] endif + call tutor#SetupVim() exe "edit ".l:to_open endfunction diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 02fe971f6a..bbf3da8de7 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -5303,9 +5303,9 @@ A jump table for the options with a short description can be found at |Q_op|. % When included, save and restore the buffer list. If Vim is started with a file name argument, the buffer list is not restored. If Vim is started without a file name argument, the - buffer list is restored from the shada file. Buffers - without a file name and buffers for help files are not written - to the shada file. + buffer list is restored from the shada file. Quickfix + ('buftype'), unlisted ('buflisted'), unnamed and buffers on + removable media (|shada-r|) are not saved. When followed by a number, the number specifies the maximum number of buffers that are stored. Without a number all buffers are stored. diff --git a/runtime/ftplugin/tutor.vim b/runtime/ftplugin/tutor.vim index 0a28d7def4..1579753170 100644 --- a/runtime/ftplugin/tutor.vim +++ b/runtime/ftplugin/tutor.vim @@ -21,8 +21,9 @@ setlocal iskeyword=@,-,_ setlocal foldmethod=expr setlocal foldexpr=tutor#TutorFolds() -setlocal foldcolumn=3 +setlocal foldcolumn=1 setlocal foldlevel=4 +setlocal nowrap setlocal statusline=%{toupper(expand('%:t:r'))}\ tutorial%= setlocal statusline+=%{tutor#InfoText()} diff --git a/runtime/tutor/en/vim-01-beginner.tutor b/runtime/tutor/en/vim-01-beginner.tutor index f791e727e7..47d4ed06a1 100644 --- a/runtime/tutor/en/vim-01-beginner.tutor +++ b/runtime/tutor/en/vim-01-beginner.tutor @@ -7,6 +7,12 @@ IMPORTANT to remember that this tutor is set up to teach by use. That means that you need to do the exercises to learn them properly. If you only read the text, you will soon forget what is most important! +For now, make sure that your Shift-Lock key is NOT depressed and press the `j`{normal} +key enough times to move the cursor so that Lesson 0 completely fills the +screen. + +# Lesson 0 + NOTE: The commands in the lessons will modify the text, but those changes won't be saved. Don't worry about messing things up; just remember that pressing [<Esc>](<Esc>) and then [u](u) will undo the latest change. @@ -30,9 +36,7 @@ or press a sequence of keys Text within <'s and >'s (like `<Enter>`{normal}) describes a key to press instead of text to type. -Now, make sure that your Shift-Lock key is NOT depressed and press the `j`{normal} -key enough times to move the cursor so that Lesson 1.1 completely fills the -screen. +Now, move to the next lesson (remember, use j). ## Lesson 1.1: MOVING THE CURSOR diff --git a/src/nvim/shada.c b/src/nvim/shada.c index 231dad07e5..e21c6f17fe 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -43,6 +43,7 @@ #include "nvim/path.h" #include "nvim/fileio.h" #include "nvim/strings.h" +#include "nvim/quickfix.h" #include "nvim/lib/khash.h" #include "nvim/lib/kvec.h" @@ -2484,8 +2485,11 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer, // Write buffer list if (find_shada_parameter('%') != NULL) { size_t buf_count = 0; +#define IGNORE_BUF(buf)\ + (buf->b_ffname == NULL || !buf->b_p_bl || bt_quickfix(buf) \ + || in_bufset(&removable_bufs, buf)) FOR_ALL_BUFFERS(buf) { - if (buf->b_ffname != NULL && !in_bufset(&removable_bufs, buf)) { + if (!IGNORE_BUF(buf)) { buf_count++; } } @@ -2503,7 +2507,7 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer, }; size_t i = 0; FOR_ALL_BUFFERS(buf) { - if (buf->b_ffname == NULL || in_bufset(&removable_bufs, buf)) { + if (IGNORE_BUF(buf)) { continue; } buflist_entry.data.buffer_list.buffers[i] = (struct buffer_list_buffer) { @@ -2519,6 +2523,7 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer, goto shada_write_exit; } xfree(buflist_entry.data.buffer_list.buffers); +#undef IGNORE_BUF } // Write some of the variables diff --git a/test/functional/shada/buffers_spec.lua b/test/functional/shada/buffers_spec.lua index fd0c5e9a39..fd4809e01a 100644 --- a/test/functional/shada/buffers_spec.lua +++ b/test/functional/shada/buffers_spec.lua @@ -1,7 +1,7 @@ -- ShaDa buffer list saving/reading support local helpers = require('test.functional.helpers') -local nvim_command, funcs, eq = - helpers.command, helpers.funcs, helpers.eq +local nvim_command, funcs, eq, curbufmeths = + helpers.command, helpers.funcs, helpers.eq, helpers.curbufmeths local shada_helpers = require('test.functional.shada.helpers') local reset, set_additional_cmd, clear = @@ -48,4 +48,43 @@ describe('ShaDa support code', function() eq(1, funcs.bufnr('$')) eq('', funcs.bufname(1)) end) + + it('does not dump unlisted buffer', function() + set_additional_cmd('set shada+=%') + reset() + nvim_command('edit ' .. testfilename) + nvim_command('edit ' .. testfilename_2) + curbufmeths.set_option('buflisted', false) + nvim_command('qall') + reset() + eq(2, funcs.bufnr('$')) + eq('', funcs.bufname(1)) + eq(testfilename, funcs.bufname(2)) + end) + + it('does not dump quickfix buffer', function() + set_additional_cmd('set shada+=%') + reset() + nvim_command('edit ' .. testfilename) + nvim_command('edit ' .. testfilename_2) + curbufmeths.set_option('buftype', 'quickfix') + nvim_command('qall') + reset() + eq(2, funcs.bufnr('$')) + eq('', funcs.bufname(1)) + eq(testfilename, funcs.bufname(2)) + end) + + it('does not dump unnamed buffers', function() + set_additional_cmd('set shada+=% hidden') + reset() + curbufmeths.set_line(0, 'foo') + nvim_command('enew') + curbufmeths.set_line(0, 'bar') + eq(2, funcs.bufnr('$')) + nvim_command('qall!') + reset() + eq(1, funcs.bufnr('$')) + eq('', funcs.bufname(1)) + end) end) |