feat: cmdheight=0 #16251

Fix https://github.com/neovim/neovim/issues/1004

Limitation: All outputs need hit-enter prompt.

Related:
https://github.com/neovim/neovim/pull/6732
https://github.com/neovim/neovim/pull/4382
This commit is contained in:
Shougo
2022-06-13 18:40:51 +09:00
committed by GitHub
parent 2f71d4708e
commit 663cbe2620
13 changed files with 247 additions and 36 deletions

View File

@@ -108,11 +108,9 @@ typedef enum {
kCmdRedrawAll,
} CmdRedraw;
/*
* Variables shared between getcmdline(), redrawcmdline() and others.
* These need to be saved when using CTRL-R |, that's why they are in a
* structure.
*/
// Variables shared between getcmdline(), redrawcmdline() and others.
// These need to be saved when using CTRL-R |, that's why they are in a
// structure.
struct cmdline_info {
char_u *cmdbuff; // pointer to command line buffer
int cmdbufflen; // length of cmdbuff
@@ -139,6 +137,7 @@ struct cmdline_info {
bool special_shift; ///< shift of last putcmdline char
CmdRedraw redraw_state; ///< needed redraw for external cmdline
};
/// Last value of prompt_id, incremented when doing new prompt
static unsigned last_prompt_id = 0;
@@ -689,6 +688,14 @@ static void finish_incsearch_highlighting(int gotesc, incsearch_state_T *s, bool
/// @param init_ccline clear ccline first
static uint8_t *command_line_enter(int firstc, long count, int indent, bool init_ccline)
{
bool cmdheight0 = p_ch < 1 && !ui_has(kUIMessages) && vpeekc() == NUL;
if (cmdheight0) {
// If cmdheight is 0, cmdheight must be set to 1 when we enter command line.
set_option_value("ch", 1L, NULL, 0);
redraw_statuslines();
}
// can be invoked recursively, identify each level
static int cmdline_level = 0;
cmdline_level++;
@@ -976,6 +983,11 @@ theend:
ccline.cmdbuff = NULL;
}
if (cmdheight0) {
// Restore cmdheight
set_option_value("ch", 0L, NULL, 0);
}
return p;
}
@@ -2670,6 +2682,12 @@ char *getcmdline_prompt(const char firstc, const char *const prompt, const int a
return ret;
}
// Return current cmdline prompt
char_u *get_cmdprompt(void)
{
return ccline.cmdprompt;
}
/*
* Return TRUE when the text must not be changed and we can't switch to
* another window or buffer. Used when editing the command line etc.
@@ -3777,7 +3795,7 @@ void redrawcmd(void)
msg_no_more = TRUE;
draw_cmdline(0, ccline.cmdlen);
msg_clr_eos();
msg_no_more = FALSE;
msg_no_more = false;
ccline.cmdspos = cmd_screencol(ccline.cmdpos);