summaryrefslogtreecommitdiffstatshomepage
path: root/test/functional/legacy/cmdwin_spec.lua
blob: 8521ab5bc1d3ff603bf86342f1831ce58b2d4998 (plain)
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')

local clear = n.clear
local command = n.command
local feed = n.feed

describe('cmdwin', function()
  before_each(clear)

  -- oldtest: Test_cmdwin_interrupted()
  it('still uses a new buffer when interrupting more prompt on open', function()
    local screen = Screen.new(30, 16)
    command('set more')
    command('autocmd WinNew * highlight')
    feed('q:')
    screen:expect({ any = vim.pesc('{6:-- More --}^') })
    feed('q')
    screen:expect([[
                                    |
      {1:~                             }|*5
      {2:[No Name]                     }|
      {1::}^                             |
      {1:~                             }|*6
      {3:[Command Line]                }|
                                    |
    ]])
    feed([[aecho 'done']])
    screen:expect([[
                                    |
      {1:~                             }|*5
      {2:[No Name]                     }|
      {1::}echo 'done'^                  |
      {1:~                             }|*6
      {3:[Command Line]                }|
      {5:-- INSERT --}                  |
    ]])
    feed('<CR>')
    screen:expect([[
      ^                              |
      {1:~                             }|*14
      done                          |
    ]])
  end)

  -- oldtest: Test_cmdwin_showcmd()
  it('has correct showcmd', function()
    local screen = Screen.new(60, 18)
    command('set showcmd')
    for _, keys in ipairs({ 'q:', ':<C-F>' }) do
      feed(keys)
      local fmt = [[
                                                                    |
        {1:~                                                           }|*7
        {2:[No Name]                                                   }|
        {1::}^                                                           |
        {1:~                                                           }|*6
        {3:[Command Line]                                              }|
        :                                                %s |
      ]]
      screen:expect(fmt:format('          '))
      feed('"')
      screen:expect(fmt:format('"         '))
      feed('x')
      screen:expect(fmt:format('"x        '))
      feed('y')
      screen:expect(fmt:format('"xy       '))
      feed('y')
      screen:expect(fmt:format('          '))
      feed('<C-C>')
      n.poke_eventloop()
      feed('<C-C>')
      screen:expect([[
        ^                                                            |
        {1:~                                                           }|*16
                                                                    |
      ]])
    end
  end)

  -- oldtest: Test_cmdwin_no_prefix_on_wrapped_line()
  it('prefix char is not drawn on wrapped screen line', function()
    local screen = Screen.new(40, 12)
    local cmd = 'echo "' .. ('a'):rep(40 - 8) .. '"XYZ'
    feed(':' .. cmd .. '<C-F>')
    screen:expect([[
                                              |
      {1:~                                       }|
      {2:[No Name]                               }|
      {1::}echo "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"|
       XY^Z                                    |
      {1:~                                       }|*5
      {3:[Command Line]                          }|
                                              |
    ]])
  end)
end)