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