edit_spec.lua 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. local n = require('test.functional.testnvim')()
  2. local Screen = require('test.functional.ui.screen')
  3. local clear = n.clear
  4. local command = n.command
  5. local expect = n.expect
  6. local feed = n.feed
  7. local sleep = vim.uv.sleep
  8. before_each(clear)
  9. describe('edit', function()
  10. -- oldtest: Test_autoindent_remove_indent()
  11. it('autoindent removes indent when Insert mode is stopped', function()
  12. command('set autoindent')
  13. -- leaving insert mode in a new line with indent added by autoindent, should
  14. -- remove the indent.
  15. feed('i<Tab>foo<CR><Esc>')
  16. -- Need to delay for sometime, otherwise the code in getchar.c will not be
  17. -- exercised.
  18. sleep(50)
  19. -- when a line is wrapped and the cursor is at the start of the second line,
  20. -- leaving insert mode, should move the cursor back to the first line.
  21. feed('o' .. ('x'):rep(20) .. '<Esc>')
  22. -- Need to delay for sometime, otherwise the code in getchar.c will not be
  23. -- exercised.
  24. sleep(50)
  25. expect('\tfoo\n\n' .. ('x'):rep(20))
  26. end)
  27. -- oldtest: Test_edit_insert_reg()
  28. it('inserting a register using CTRL-R', function()
  29. local screen = Screen.new(10, 6)
  30. feed('a<C-R>')
  31. screen:expect([[
  32. {18:^"} |
  33. {1:~ }|*4
  34. {5:-- INSERT --}|
  35. ]])
  36. feed('=')
  37. screen:expect([[
  38. {18:"} |
  39. {1:~ }|*4
  40. =^ |
  41. ]])
  42. feed([['r'<CR><Esc>]])
  43. expect('r')
  44. -- Test for inserting null and empty list
  45. feed('a<C-R>=v:_null_list<CR><Esc>')
  46. feed('a<C-R>=[]<CR><Esc>')
  47. expect('r')
  48. end)
  49. -- oldtest: Test_edit_ctrl_r_failed()
  50. it('positioning cursor after CTRL-R expression failed', function()
  51. local screen = Screen.new(60, 6)
  52. feed('i<C-R>')
  53. screen:expect([[
  54. {18:^"} |
  55. {1:~ }|*4
  56. {5:-- INSERT --} |
  57. ]])
  58. feed('=0z')
  59. screen:expect([[
  60. {18:"} |
  61. {1:~ }|*4
  62. ={26:0}{9:z}^ |
  63. ]])
  64. -- trying to insert a blob produces an error
  65. feed('<CR>')
  66. screen:expect([[
  67. {18:"} |
  68. {1:~ }|
  69. {3: }|
  70. ={26:0}{9:z} |
  71. {9:E976: Using a Blob as a String} |
  72. {6:Press ENTER or type command to continue}^ |
  73. ]])
  74. feed(':')
  75. screen:expect([[
  76. :^ |
  77. {1:~ }|*4
  78. {5:-- INSERT --} |
  79. ]])
  80. -- ending Insert mode should put the cursor back on the ':'
  81. feed('<Esc>')
  82. screen:expect([[
  83. ^: |
  84. {1:~ }|*4
  85. |
  86. ]])
  87. end)
  88. end)