Repository: neovim
Issue: Make terminal buffer behave more like normal buffers
Labels: enhancement,terminal

I notice the terminal buffer has a few things which are inconsistent with "normal" text buffers.  I think it would be better and more logical if terminal buffers work more like regular buffers.

# `set list` not working in terminal buffers.

One thing thing which is inconsistent with normal buffers is that `set list` will not work on terminal buffers.

# Missing output becomes blank lines

When a terminal window has been opened and the user has typed a few commands, such that the whole terminal window is not filled up and exits from terminal mode, there are a lot of blank lines in the terminal buffer.

Example (user is in terminal mode):

    +-------------------------------------------------------------------------+
    |$ ls                                                                     |
    |decode.c  encode.c  executor.c  gc.c  typval.c           typval_encode.h |
    |decode.h  encode.h  executor.h  gc.h  typval_encode.c.h  typval.h        |
    |$ █                                                                      |
    |                                                                         |
    |                                                                         |
    |                                                                         |
    |                                                                         |
    |                                                                         |
    |--TERMINAL--                                                             |
    +-------------------------------------------------------------------------+

What happens when user exits from terminal mode:

    +-------------------------------------------------------------------------+
    |$ ls                                                                     |
    |decode.c  encode.c  executor.c  gc.c  typval.c           typval_encode.h |
    |decode.h  encode.h  executor.h  gc.h  typval_encode.c.h  typval.h        |
    |$                                                                        |
    |                                                                         |
    |                                                                         |
    |                                                                         |
    |                                                                         |
    |█                                                                        |
    |                                                                         |
    +-------------------------------------------------------------------------+

The current behavior is inconsistent because the missing `~`-signs for missing text will show up and the user cannot move past the last terminal output line if and only if the terminal buffer output overflows the current window.

I think it would make more sense if lines which haven't been output by the terminal job will become missing lines in the buffer, even when the terminal output have not overflown.

# Proposal

I think it would be better if `set list` works in the terminal buffer, and lines which have not been output by the terminal application will always show up as empty lines in the terminal buffer.

A side effect of having missing lines not becoming blank lines in the terminal buffer is that the cursor position can't start at the lower left corner anymore when exiting terminal mode.  I propose that this behavior is changed so the cursor position when exiting terminal mode will always be the position which the cursor had when inside terminal mode.

What is proposed to happen when user exits from terminal mode (note the `~` characters indicating missing lines in the buffer):

    +-------------------------------------------------------------------------+
    |$ ls                                                                     |
    |decode.c  encode.c  executor.c  gc.c  typval.c           typval_encode.h |
    |decode.h  encode.h  executor.h  gc.h  typval_encode.c.h  typval.h        |
    |$ █                                                                      |
    |~                                                                        |
    |~                                                                        |
    |~                                                                        |
    |~                                                                        |
    |~                                                                        |
    |                                                                         |
    +-------------------------------------------------------------------------+

Implementing this should be possible. Vim has implemented the kind of behavior which I propose.