"Fossies" - the Fresh Open Source Software Archive

Member "neovim-0.3.8/test/functional/legacy/004_bufenter_with_modelines_spec.lua" (3 Jul 2019, 2093 Bytes) of package /linux/misc/neovim-0.3.8.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Lua source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 -- Test for autocommand that changes current buffer on BufEnter event.
    2 -- Check if modelines are interpreted for the correct buffer.
    3 
    4 local helpers = require('test.functional.helpers')(after_each)
    5 local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
    6 local feed_command, expect = helpers.feed_command, helpers.expect
    7 
    8 describe('BufEnter with modelines', function()
    9   setup(clear)
   10 
   11   it('is working', function()
   12     insert([[
   13       startstart
   14       start of test file Xxx
   15       vim: set noai :
   16           this is a test
   17           this is a test
   18           this is a test
   19           this is a test
   20       end of test file Xxx]])
   21 
   22     feed_command('au BufEnter Xxx brew')
   23 
   24     -- Write test file Xxx
   25     feed_command('/start of')
   26     feed_command('.,/end of/w! Xxx')
   27     feed_command('set ai modeline modelines=3')
   28 
   29     -- Split to Xxx, autocmd will do :brew
   30     feed_command('sp Xxx')
   31 
   32     -- Append text with autoindent to this file
   33     feed('G?this is a<CR>')
   34     feed('othis should be auto-indented<Esc>')
   35 
   36     -- Go to Xxx, no autocmd anymore
   37     feed_command('au! BufEnter Xxx')
   38     feed_command('buf Xxx')
   39 
   40     -- Append text without autoindent to Xxx
   41     feed('G?this is a<CR>')
   42     feed('othis should be in column 1<Esc>')
   43     feed_command('wq')
   44 
   45     -- Include Xxx in the current file
   46     feed('G:r Xxx<CR>')
   47 
   48     -- Vim issue #57 do not move cursor on <c-o> when autoindent is set
   49     feed_command('set fo+=r')
   50     feed('G')
   51     feed('o# abcdef<Esc>2hi<CR><c-o>d0<Esc>')
   52     feed('o# abcdef<Esc>2hi<c-o>d0<Esc>')
   53 
   54     expect([[
   55       startstart
   56       start of test file Xxx
   57       vim: set noai :
   58           this is a test
   59           this is a test
   60           this is a test
   61           this is a test
   62           this should be auto-indented
   63       end of test file Xxx
   64       start of test file Xxx
   65       vim: set noai :
   66           this is a test
   67           this is a test
   68           this is a test
   69           this is a test
   70       this should be in column 1
   71       end of test file Xxx
   72       # abc
   73       def
   74       def]])
   75   end)
   76 
   77   teardown(function()
   78     os.remove('Xxx')
   79   end)
   80 end)