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

Code before:
      local _, new_pid = server_session:request('nvim_call_function', 'getpid', {})
      t.neq(server_pid, new_pid)
      server_pid = new_pid
    end

    tt.feed_data(':1restart\013')
    screen:expect({ any = vim.pesc('{101:E481: No range allowed}') })

    tt.feed_data(':restart foo\013')
    screen:expect({ any = vim.pesc('{101:E488: Trailing characters: foo}') })

    -- Check ":restart" on an unmodified buffer.
    tt.feed_data(':restart\013')
    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')

Review comment (suggestion):
`+` has special meaning in a Lua pattern
```suggestion
    screen:expect({ any = vim.pesc('+cmd did not quit the server') })
```

Code after:
      local _, new_pid = server_session:request('nvim_call_function', 'getpid', {})
      t.neq(server_pid, new_pid)
      server_pid = new_pid
    end

    tt.feed_data(':1restart\013')
    screen:expect({ any = vim.pesc('{101:E481: No range allowed}') })

    tt.feed_data(':restart foo\013')
    screen:expect({ any = vim.pesc('{101:E488: Trailing characters: foo}') })

    -- Check ":restart" on an unmodified buffer.
    tt.feed_data(':restart\013')
    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')