aboutsummaryrefslogtreecommitdiff
path: root/test/functional/options/shortmess_spec.lua
blob: 04dbada7d84e06400243f4f863890ad4305b0a26 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')

local clear = n.clear
local command = n.command
local eq = t.eq
local eval = n.eval
local feed = n.feed

describe("'shortmess'", function()
  local screen

  before_each(function()
    clear()
    screen = Screen.new(42, 5)
  end)

  describe('"F" flag', function()
    it('hides :edit fileinfo messages', function()
      command('set hidden')
      command('set shortmess-=F')
      feed(':edit foo<CR>')
      screen:expect([[
        ^                                          |
        {1:~                                         }|*3
        "foo" [New]                               |
      ]])
      eq(1, eval('bufnr("%")'))

      command('set shortmess+=F')
      feed(':edit bar<CR>')
      screen:expect([[
        ^                                          |
        {1:~                                         }|*3
        :edit bar                                 |
      ]])
      eq(2, eval('bufnr("%")'))
    end)

    it('hides :bnext, :bprevious fileinfo messages', function()
      command('set hidden')
      command('set shortmess-=F')
      feed(':edit foo<CR>')
      screen:expect([[
        ^                                          |
        {1:~                                         }|*3
        "foo" [New]                               |
      ]])
      eq(1, eval('bufnr("%")'))
      feed(':edit bar<CR>')
      screen:expect([[
        ^                                          |
        {1:~                                         }|*3
        "bar" [New]                               |
      ]])
      eq(2, eval('bufnr("%")'))
      feed(':bprevious<CR>')
      screen:expect([[
        ^                                          |
        {1:~                                         }|*3
        "foo" [New] --No lines in buffer--        |
      ]])
      eq(1, eval('bufnr("%")'))

      command('set shortmess+=F')
      feed(':bnext<CR>')
      screen:expect([[
        ^                                          |
        {1:~                                         }|*3
        :bnext                                    |
      ]])
      eq(2, eval('bufnr("%")'))
      feed(':bprevious<CR>')
      screen:expect([[
        ^                                          |
        {1:~                                         }|*3
        :bprevious                                |
      ]])
      eq(1, eval('bufnr("%")'))
    end)
  end)
end)