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

Code before:
    tt.feed_data(':restart\013')
    screen:expect([[
      this will be removed                              |
      {5:                                                  }|
      {8:E37: No write since last change}                   |
      {8:E162: No write since last change for buffer "[No N}|
      {8:ame]"}                                             |
      {10:Press ENTER or type command to continue}^           |
      {3:-- TERMINAL --}                                    |
    ]])

    -- Check ":restart!".
    tt.feed_data(':restart!\013')
    screen:expect(s0)
    restart_pid_check()

    tt.feed_data(':echo\n')
    screen:expect([[
      ^                                                  |
      {4:~                                                 }|*3
      {5:[No Name]                                         }|
                                                        |
      {3:-- TERMINAL --}                                    |
    ]])

    -- :restart also works without --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()

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

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

Review comment (suggestion):
Took me a second to understand this
```suggestion
    -- :restart avoids a --listen conflict when server exit is delayed.
```

Code after:
    -- Check ":restart" on a modified buffer.
    tt.feed_data(':restart\013')
    screen:expect([[
      this will be removed                              |
      {5:                                                  }|
      {8:E37: No write since last change}                   |
      {8:E162: No write since last change for buffer "[No N}|
      {8:ame]"}                                             |
      {10:Press ENTER or type command to continue}^           |
      {3:-- TERMINAL --}                                    |
    ]])

    -- Check ":restart!".
    tt.feed_data(':restart!\013')
    screen:expect(s0)
    restart_pid_check()

    tt.feed_data(':echo\n')
    screen:expect([[
      ^                                                  |
      {4:~                                                 }|*3
      {5:[No Name]                                         }|
                                                        |
      {3:-- TERMINAL --}                                    |
    ]])

    -- 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()

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

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