Repository: neovim/neovim
File: test/functional/legacy/prompt_buffer_spec.lua (Lua)

Code before:
      other buffer             |
      % line1                  |
      line2^                    |
      {1:~                        }|*6
      {5:-- INSERT --}             |
    ]])

    -- ensure cursor gets adjusted to end of user-text to prompt when insert mode
    -- is entered from readonly region of prompt buffer
    local prompt_pos = api.nvim_buf_get_mark(0, ':')
    feed('<esc>')
    -- works before prompt
    api.nvim_win_set_cursor(0, { prompt_pos[1] - 1, 0 })
    screen:expect([[
      ^other buffer             |
      % line1                  |
      line2                    |
      {1:~                        }|*6
                               |
    ]])
    feed('a')
    feed('<esc>')
    screen:expect([[
      other buffer             |
      %^ line1                  |
      line2                    |
      {1:~                        }|*6
                               |
    ]])
    -- works on prompt
    api.nvim_win_set_cursor(0, { prompt_pos[1], 0 })
    screen:expect([[
      other buffer             |
      ^% line1                  |
      line2                    |
      {1:~                        }|*6
                               |
    ]])
    feed('a')
    feed('<esc>')
    screen:expect([[
      other buffer             |
      %^ line1                  |
      line2                    |
      {1:~                        }|*6
                               |
    ]])

    -- i_<Left> i_<C-Left> i_<Home> i_<End> keys on prompt-line doesn't put cursor
    -- at end of text
    feed('a<Left><C-Left>')

Review comment (suggestion):
This comment above seems no longer correct:
```lua
    -- ensure cursor gets adjusted to end of user-text to prompt when insert mode
    -- is entered from readonly region of prompt buffer
```

Code after:
      other buffer             |
      % line1                  |
      line2^                    |
      {1:~                        }|*6
      {5:-- INSERT --}             |
    ]])

    -- ensure cursor gets placed on first line of user input.
    -- when insert mode is entered from read-only region of prompt buffer.
    local prompt_pos = api.nvim_buf_get_mark(0, ':')
    feed('<esc>')
    -- works before prompt
    api.nvim_win_set_cursor(0, { prompt_pos[1] - 1, 0 })
    screen:expect([[
      ^other buffer             |
      % line1                  |
      line2                    |
      {1:~                        }|*6
                               |
    ]])
    feed('a')
    feed('<esc>')
    screen:expect([[
      other buffer             |
      %^ line1                  |
      line2                    |
      {1:~                        }|*6
                               |
    ]])
    -- works on prompt
    api.nvim_win_set_cursor(0, { prompt_pos[1], 0 })
    screen:expect([[
      other buffer             |
      ^% line1                  |
      line2                    |
      {1:~                        }|*6
                               |
    ]])
    feed('a')
    feed('<esc>')
    screen:expect([[
      other buffer             |
      %^ line1                  |
      line2                    |
      {1:~                        }|*6
                               |
    ]])

    -- i_<Left> i_<C-Left> i_<Home> i_<End> keys on prompt-line doesn't put cursor
    -- at end of text
    feed('a<Left><C-Left>')