Repository: neovim/neovim
File: test/functional/terminal/tui_spec.lua (Lua)

Code before:
    screen_expect(s0)
    restart_pid_check()
    gui_running_check()

    -- Check ":restart +qall" on an unmodified buffer.
    tt.feed_data(':restart +qall\013')
    screen_expect(s0)
    restart_pid_check()
    gui_running_check()

    -- Check ":restart +echo" cannot restart server.
    tt.feed_data(':restart +echo\013')
    screen:expect({ any = '+cmd did not quit the server' })

    tt.feed_data('ithis will be removed\027')
    screen_expect([[
      this will be remove^d                              |
      {100:~                                                 }|*3
      {3:[No Name] [+]                                     }|
                                                        |
      {5:-- TERMINAL --}                                    |
    ]])

    -- Check ":confirm restart" on a modified buffer.
    tt.feed_data(':confirm restart\013')
    screen:expect({ any = 'Save changes to "Untitled"?' })

    -- Cancel the operation (abandons restart).
    tt.feed_data('C\013')

    -- Check ":restart" on the modified buffer.
    tt.feed_data(':restart\013')
    screen_expect(s0)
    restart_pid_check()
    gui_running_check()

    -- No --listen conflict when server exit is delayed.
    feed_data(':lua vim.schedule(function() vim.wait(100) end); vim.cmd.restart()\n')
    screen_expect(s0)
    restart_pid_check()
    gui_running_check()

    screen:try_resize(60, 6)
    screen_expect([[
      ^                                                            |
      {100:~                                                           }|*2
      {3:[No Name]                                                   }|
                                                                  |
      {5:-- TERMINAL --}                                              |
    ]])


Review comment (suggestion):
`?` has special meaning in a Lua pattern
```suggestion
    screen:expect({ any = vim.pesc('Save changes to "Untitled"?') })
```

Code after:
    screen_expect(s0)
    restart_pid_check()
    gui_running_check()

    -- Check ":restart +qall" on an unmodified buffer.
    tt.feed_data(':restart +qall\013')
    screen_expect(s0)
    restart_pid_check()
    gui_running_check()

    -- Check ":restart +echo" cannot restart server.
    tt.feed_data(':restart +echo\013')
    screen:expect({ any = vim.pesc('+cmd did not quit the server') })

    tt.feed_data('ithis will be removed\027')
    screen_expect([[
      this will be remove^d                              |
      {100:~                                                 }|*3
      {3:[No Name] [+]                                     }|
                                                        |
      {5:-- TERMINAL --}                                    |
    ]])

    -- Check ":confirm restart" on a modified buffer.
    tt.feed_data(':confirm restart\013')
    screen:expect({ any = vim.pesc('Save changes to "Untitled"?') })

    -- Cancel the operation (abandons restart).
    tt.feed_data('C\013')

    -- Check ":restart" on the modified buffer.
    tt.feed_data(':restart\013')
    screen_expect(s0)
    restart_pid_check()
    gui_running_check()

    -- No --listen conflict when server exit is delayed.
    feed_data(':lua vim.schedule(function() vim.wait(100) end); vim.cmd.restart()\n')
    screen_expect(s0)
    restart_pid_check()
    gui_running_check()

    screen:try_resize(60, 6)
    screen_expect([[
      ^                                                            |
      {100:~                                                           }|*2
      {3:[No Name]                                                   }|
                                                                  |
      {5:-- TERMINAL --}                                              |
    ]])