robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

master
2.2 KiB77 linesraw
1local t = require('test.testutil')
2local n = require('test.functional.testnvim')()
3local tt = require('test.functional.testterm')
4
5local describe, it, before_each, teardown = t.describe, t.it, t.before_each, t.teardown
6local clear = n.clear
7local feed_data = tt.feed_data
8
9describe('autoread TUI FocusGained/FocusLost', function()
10  local f1 = 'xtest-foo'
11  local screen
12
13  before_each(function()
14    clear()
15    screen = tt.setup_child_nvim({
16      '-u',
17      'NONE',
18      '-i',
19      'NONE',
20      '--cmd',
21      'colorscheme vim',
22      '--cmd',
23      'set noswapfile noshowcmd noruler notermguicolors',
24    })
25  end)
26
27  teardown(function()
28    os.remove(f1)
29  end)
30
31  it('external file change', function()
32    local path = f1
33    local expected_addition = [[
34    line 1
35    line 2
36    line 3
37    line 4
38    ]]
39
40    t.write_file(path, '')
41    local atime = os.time() - 10
42    vim.uv.fs_utime(path, atime, atime)
43
44    screen:expect([[
45      ^                                                  |
46      {100:~                                                 }|*3
47      {3:[No Name]                                         }|
48                                                        |
49      {5:-- TERMINAL --}                                    |
50    ]])
51    n.feed(':edit ' .. path .. '<CR>')
52    screen:expect([[
53      ^                                                  |
54      {100:~                                                 }|*3
55      {3:xtest-foo                                         }|
56      :edit xtest-foo                                   |
57      {5:-- TERMINAL --}                                    |
58    ]])
59    feed_data('\027[O')
60    feed_data('\027[O')
61    screen:expect_unchanged()
62
63    t.write_file(path, expected_addition)
64
65    feed_data('\027[I')
66
67    screen:expect([[
68      ^line 1                                            |
69      line 2                                            |
70      line 3                                            |
71      line 4                                            |
72      {3:xtest-foo                                         }|
73      :edit xtest-foo                                   |
74      {5:-- TERMINAL --}                                    |
75    ]])
76  end)
77end)