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

Code before:
    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')
    screen:expect({ any = vim.pesc('[No Name]') })

    -- Check :restart respects confirm
    tt.feed_data(':set confirm\013')
    tt.feed_data(':restart\013')
    screen:expect({ any = vim.pesc('Save changes to "Untitled"?') })
    tt.feed_data('C\013')
    screen:expect({ any = vim.pesc('[No Name]') })
    tt.feed_data(':set noconfirm\013')

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

    -- Check if the -c <cmd> runs after restart.
    screen_expect(s1)
    tt.feed_data('\013')
    restart_pid_check()
    gui_running_check()

    -- 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.

Review comment (suggestion):
```suggestion
    -- Check :restart respects 'confirm' option.
```

Code after:
    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')
    screen:expect({ any = vim.pesc('[No Name]') })

    -- Check :restart respects 'confirm' option.
    tt.feed_data(':set confirm\013')
    tt.feed_data(':restart\013')
    screen:expect({ any = vim.pesc('Save changes to "Untitled"?') })
    tt.feed_data('C\013')
    screen:expect({ any = vim.pesc('[No Name]') })
    tt.feed_data(':set noconfirm\013')

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

    -- Check if the -c <cmd> runs after restart.
    screen_expect(s1)
    tt.feed_data('\013')
    restart_pid_check()
    gui_running_check()

    -- 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.