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

Code before:
      {3:[No Name]                                                   }|
                                                                  |
      {5:-- TERMINAL --}                                              |
    ]])

    --- Check that ":restart" uses the updated size after terminal resize.
    tt.feed_data(':restart\013')
    screen_expect([[
      ^                                                            |
      {100:~                                                           }|*2
      {3:[No Name]                                                   }|
      {MATCH:%d+ +}|
      {5:-- TERMINAL --}                                              |
    ]])
    restart_pid_check()
    gui_running_check()
  end)
end)

describe('TUI :connect', function()
  if is_os('win') then
    -- :connect relies on :detach which currently doesn't work on windows
    return
  end

  it('requires an argument', function()
    n.clear()
    finally(function()
      n.check_close()
    end)

    local server1 = new_pipename()
    local screen = tt.setup_child_nvim({
      '--listen',
      server1,
      '-u',
      'NONE',
    })
    tt.feed_data(':connect\013')
    screen:expect([[
      ^                                                  |
      ~                                                 |*3
      [No Name]                       0,0-1          All|
      E471: Argument required                           |
      {5:-- TERMINAL --}                                    |
    ]])

    screen:detach()
  end)
  it('leaves the current server running', function()
    n.clear()

Review comment (suggestion):
test is too verbose just to check that a commmand requires an argument. that only requires ~2 lines to check. also rename this to: 
```suggestion
  it('validation', function()
```

then we can add more validation later.

Code after:
    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 ":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.
    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 --}                                              |
    ]])

    --- Check that ":restart" uses the updated size after terminal resize.