2024-04-20 08:44:13 -07:00
|
|
|
local t = require('test.testutil')
|
|
|
|
local n = require('test.functional.testnvim')()
|
2024-09-15 03:28:14 -07:00
|
|
|
local tt = require('test.functional.testterm')
|
2024-04-20 08:44:13 -07:00
|
|
|
|
|
|
|
local clear = n.clear
|
|
|
|
local feed_command = n.feed_command
|
2024-04-08 02:03:20 -07:00
|
|
|
local feed_data = tt.feed_data
|
2020-06-29 12:50:12 -07:00
|
|
|
|
2024-04-08 02:03:20 -07:00
|
|
|
if t.skip(t.is_os('win')) then
|
2022-11-21 17:13:30 -07:00
|
|
|
return
|
|
|
|
end
|
2020-06-29 12:50:12 -07:00
|
|
|
|
|
|
|
describe('autoread TUI FocusGained/FocusLost', function()
|
2021-04-14 17:42:34 -07:00
|
|
|
local f1 = 'xtest-foo'
|
2020-06-29 12:50:12 -07:00
|
|
|
local screen
|
|
|
|
|
|
|
|
before_each(function()
|
|
|
|
clear()
|
2024-04-08 02:03:20 -07:00
|
|
|
screen = tt.setup_child_nvim({
|
2023-12-05 15:26:46 -07:00
|
|
|
'-u',
|
|
|
|
'NONE',
|
|
|
|
'-i',
|
|
|
|
'NONE',
|
|
|
|
'--cmd',
|
|
|
|
'colorscheme vim',
|
|
|
|
'--cmd',
|
|
|
|
'set noswapfile noshowcmd noruler notermguicolors',
|
|
|
|
})
|
2020-06-29 12:50:12 -07:00
|
|
|
end)
|
|
|
|
|
2021-04-14 17:42:34 -07:00
|
|
|
teardown(function()
|
|
|
|
os.remove(f1)
|
|
|
|
end)
|
|
|
|
|
2020-06-29 12:50:12 -07:00
|
|
|
it('external file change', function()
|
2021-04-14 17:42:34 -07:00
|
|
|
local path = f1
|
2020-06-29 12:50:12 -07:00
|
|
|
local expected_addition = [[
|
|
|
|
line 1
|
|
|
|
line 2
|
|
|
|
line 3
|
|
|
|
line 4
|
|
|
|
]]
|
|
|
|
|
2024-04-08 02:03:20 -07:00
|
|
|
t.write_file(path, '')
|
2023-04-04 12:59:06 -07:00
|
|
|
local atime = os.time() - 10
|
2024-01-12 05:03:25 -07:00
|
|
|
vim.uv.fs_utime(path, atime, atime)
|
2020-06-29 12:50:12 -07:00
|
|
|
|
2022-05-02 12:10:01 -07:00
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
2024-12-17 06:11:41 -07:00
|
|
|
^ |
|
2023-12-09 05:42:00 -07:00
|
|
|
{4:~ }|*3
|
2022-05-02 12:10:01 -07:00
|
|
|
{5:[No Name] }|
|
|
|
|
|
|
|
|
|
{3:-- TERMINAL --} |
|
|
|
|
]],
|
|
|
|
}
|
|
|
|
feed_command('edit ' .. path)
|
2020-06-29 12:50:12 -07:00
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
2024-12-17 06:11:41 -07:00
|
|
|
^ |
|
2023-12-09 05:42:00 -07:00
|
|
|
{4:~ }|*3
|
2020-06-29 12:50:12 -07:00
|
|
|
{5:xtest-foo }|
|
|
|
|
:edit xtest-foo |
|
|
|
|
{3:-- TERMINAL --} |
|
|
|
|
]],
|
|
|
|
}
|
2022-05-02 12:10:01 -07:00
|
|
|
feed_data('\027[O')
|
|
|
|
feed_data('\027[O')
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
2024-12-17 06:11:41 -07:00
|
|
|
^ |
|
2023-12-09 05:42:00 -07:00
|
|
|
{4:~ }|*3
|
2022-05-02 12:10:01 -07:00
|
|
|
{5:xtest-foo }|
|
|
|
|
:edit xtest-foo |
|
|
|
|
{3:-- TERMINAL --} |
|
|
|
|
]],
|
|
|
|
unchanged = true,
|
|
|
|
}
|
2020-06-29 12:50:12 -07:00
|
|
|
|
2024-04-08 02:03:20 -07:00
|
|
|
t.write_file(path, expected_addition)
|
2020-06-29 12:50:12 -07:00
|
|
|
|
2020-07-02 11:36:14 -07:00
|
|
|
feed_data('\027[I')
|
2020-06-29 12:50:12 -07:00
|
|
|
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
2024-12-17 06:11:41 -07:00
|
|
|
^line 1 |
|
2020-06-29 12:50:12 -07:00
|
|
|
line 2 |
|
|
|
|
line 3 |
|
|
|
|
line 4 |
|
|
|
|
{5:xtest-foo }|
|
2024-03-07 15:53:43 -07:00
|
|
|
:edit xtest-foo |
|
2020-06-29 12:50:12 -07:00
|
|
|
{3:-- TERMINAL --} |
|
|
|
|
]],
|
|
|
|
}
|
|
|
|
end)
|
|
|
|
end)
|