aboutsummaryrefslogtreecommitdiff
path: root/src/nvim
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim')
-rw-r--r--src/nvim/api/options.c8
-rw-r--r--src/nvim/eval/funcs.c13
-rw-r--r--src/nvim/ex_cmds.c2
-rw-r--r--src/nvim/ex_getln.c19
-rw-r--r--src/nvim/fileio.c1
-rw-r--r--src/nvim/globals.h3
-rw-r--r--src/nvim/highlight.c4
-rw-r--r--src/nvim/lua/executor.c4
-rw-r--r--src/nvim/message.c5
-rw-r--r--src/nvim/normal.c2
-rw-r--r--src/nvim/ops.c18
-rw-r--r--src/nvim/screen.c15
-rw-r--r--src/nvim/testdir/test_ins_complete.vim2
-rw-r--r--src/nvim/testdir/test_messages.vim56
-rw-r--r--src/nvim/testdir/test_syn_attr.vim30
-rw-r--r--src/nvim/testdir/test_window_cmd.vim4
-rw-r--r--src/nvim/ui.c6
-rw-r--r--src/nvim/window.c10
18 files changed, 160 insertions, 42 deletions
diff --git a/src/nvim/api/options.c b/src/nvim/api/options.c
index 5c9eba163b..867584dd71 100644
--- a/src/nvim/api/options.c
+++ b/src/nvim/api/options.c
@@ -280,7 +280,7 @@ Object nvim_buf_get_option(Buffer buffer, String name, Error *err)
return get_option_from(buf, SREQ_BUF, name, err);
}
-/// Sets a buffer option value. Passing 'nil' as value deletes the option (only
+/// Sets a buffer option value. Passing `nil` as value deletes the option (only
/// works if there's a global fallback)
///
/// @param channel_id
@@ -318,7 +318,7 @@ Object nvim_win_get_option(Window window, String name, Error *err)
return get_option_from(win, SREQ_WIN, name, err);
}
-/// Sets a window option value. Passing 'nil' as value deletes the option(only
+/// Sets a window option value. Passing `nil` as value deletes the option (only
/// works if there's a global fallback)
///
/// @param channel_id
@@ -338,7 +338,7 @@ void nvim_win_set_option(uint64_t channel_id, Window window, String name, Object
set_option_to(channel_id, win, SREQ_WIN, name, value, err);
}
-/// Gets the value of a global or local(buffer, window) option.
+/// Gets the value of a global or local (buffer, window) option.
///
/// @param from If `type` is `SREQ_WIN` or `SREQ_BUF`, this must be a pointer
/// to the window or buffer.
@@ -393,7 +393,7 @@ Object get_option_from(void *from, int type, String name, Error *err)
return rv;
}
-/// Sets the value of a global or local(buffer, window) option.
+/// Sets the value of a global or local (buffer, window) option.
///
/// @param to If `type` is `SREQ_WIN` or `SREQ_BUF`, this must be a pointer
/// to the window or buffer.
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 2c62f56d5f..b3cfec8709 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -2899,6 +2899,11 @@ static void getchar_common(typval_T *argvars, typval_T *rettv)
no_mapping--;
allow_keys--;
+ if (!ui_has_messages()) {
+ // redraw the screen after getchar()
+ update_screen(CLEAR);
+ }
+
set_vim_var_nr(VV_MOUSE_WIN, 0);
set_vim_var_nr(VV_MOUSE_WINID, 0);
set_vim_var_nr(VV_MOUSE_LNUM, 0);
@@ -9498,8 +9503,12 @@ static void f_synIDattr(typval_T *argvars, typval_T *rettv, FunPtr fptr)
p = highlight_has_attr(id, HL_ITALIC, modec);
}
break;
- case 'n': // name
- p = get_highlight_name_ext(NULL, id - 1, false);
+ case 'n':
+ if (TOLOWER_ASC(what[1]) == 'o') { // nocombine
+ p = highlight_has_attr(id, HL_NOCOMBINE, modec);
+ } else { // name
+ p = get_highlight_name_ext(NULL, id - 1, false);
+ }
break;
case 'r': // reverse
p = highlight_has_attr(id, HL_INVERSE, modec);
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 585694a138..c765b1652d 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -3669,7 +3669,7 @@ static int do_sub(exarg_T *eap, proftime_T timeout, long cmdpreview_ns, handle_T
}
}
- bool cmdheight0 = p_ch < 1 && !ui_has(kUIMessages);
+ const bool cmdheight0 = !ui_has_messages();
if (cmdheight0) {
// If cmdheight is 0, cmdheight must be set to 1 when we enter command line.
set_option_value("ch", 1L, NULL, 0);
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 2349de299b..6240ac6b37 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -689,12 +689,22 @@ 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);
+ const bool cmdheight0 = !ui_has_messages();
if (cmdheight0) {
- // If cmdheight is 0, cmdheight must be set to 1 when we enter command line.
+ const long save_so = lastwin->w_p_so;
+
+ // If cmdheight is 0, cmdheight must be set to 1 when we enter the
+ // command line. Set "made_cmdheight_nonzero" and reset 'scrolloff' to
+ // avoid scrolling the last window.
+ made_cmdheight_nonzero = true;
+
+ lastwin->w_p_so = 0;
set_option_value("ch", 1L, NULL, 0);
update_screen(VALID); // redraw the screen NOW
+
+ made_cmdheight_nonzero = false;
+ lastwin->w_p_so = save_so;
}
// can be invoked recursively, identify each level
@@ -991,11 +1001,14 @@ theend:
}
if (cmdheight0) {
+ made_cmdheight_nonzero = true;
+
// Restore cmdheight
set_option_value("ch", 0L, NULL, 0);
-
// Redraw is needed for command line completion
redraw_all_later(CLEAR);
+
+ made_cmdheight_nonzero = false;
}
return p;
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index e0c95187cc..b98984017b 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -5270,7 +5270,6 @@ void forward_slash(char_u *fname)
return;
}
for (p = fname; *p != NUL; p++) {
- // The Big5 encoding can have '\' in the trail byte.
if (*p == '\\') {
*p = '/';
}
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index 9946085703..a41836353a 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -1084,4 +1084,7 @@ EXTERN char windowsVersion[20] INIT(= { 0 });
EXTERN int exit_need_delay INIT(= 0);
+// Set when 'cmdheight' is changed from zero to one temporarily.
+EXTERN bool made_cmdheight_nonzero INIT(= false);
+
#endif // NVIM_GLOBALS_H
diff --git a/src/nvim/highlight.c b/src/nvim/highlight.c
index 6226130322..71c7194479 100644
--- a/src/nvim/highlight.c
+++ b/src/nvim/highlight.c
@@ -778,6 +778,10 @@ Dictionary hlattrs2dict(Dictionary *hl_alloc, HlAttrs ae, bool use_rgb)
PUT_C(hl, "strikethrough", BOOLEAN_OBJ(true));
}
+ if (mask & HL_NOCOMBINE) {
+ PUT_C(hl, "nocombine", BOOLEAN_OBJ(true));
+ }
+
if (use_rgb) {
if (mask & HL_FG_INDEXED) {
PUT_C(hl, "fg_indexed", BOOLEAN_OBJ(true));
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c
index b18770d4f1..17157ccdc2 100644
--- a/src/nvim/lua/executor.c
+++ b/src/nvim/lua/executor.c
@@ -1686,7 +1686,7 @@ int nlua_expand_pat(expand_T *xp, char_u *pat, int *num_results, char ***results
lua_getfield(lstate, -1, "_expand_pat");
luaL_checktype(lstate, -1, LUA_TFUNCTION);
- // [ vim, vim._on_key, buf ]
+ // [ vim, vim._expand_pat, buf ]
lua_pushlstring(lstate, (const char *)pat, STRLEN(pat));
if (nlua_pcall(lstate, 1, 2) != 0) {
@@ -1839,7 +1839,7 @@ void nlua_execute_on_key(int c)
// [ vim ]
lua_getglobal(lstate, "vim");
- // [ vim, vim._on_key]
+ // [ vim, vim._on_key ]
lua_getfield(lstate, -1, "_on_key");
luaL_checktype(lstate, -1, LUA_TFUNCTION);
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 80d11c096b..621a9212df 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -493,6 +493,7 @@ int smsg(const char *s, ...)
va_start(arglist, s);
vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist);
va_end(arglist);
+
return msg((char *)IObuff);
}
@@ -1389,7 +1390,7 @@ void msg_start(void)
need_fileinfo = false;
}
- bool no_msg_area = !ui_has(kUIMessages) && p_ch < 1;
+ const bool no_msg_area = !ui_has_messages();
if (need_clr_eos || (no_msg_area && redrawing_cmdline)) {
// Halfway an ":echo" command and getting an (error) message: clear
@@ -3112,7 +3113,7 @@ void msg_clr_eos_force(void)
msg_row = msg_grid_pos;
}
- if (p_ch > 0) {
+ if (ui_has_messages()) {
grid_fill(&msg_grid_adj, msg_row, msg_row + 1, msg_startcol, msg_endcol,
' ', ' ', HL_ATTR(HLF_MSG));
grid_fill(&msg_grid_adj, msg_row + 1, Rows, 0, Columns,
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index e3bd4de9a0..fae22ce06f 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -2810,7 +2810,7 @@ void pop_showcmd(void)
static void display_showcmd(void)
{
- if (p_ch < 1 && !ui_has(kUIMessages)) {
+ if (!ui_has_messages()) {
return;
}
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 834415881e..cc67b0d0c1 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -893,6 +893,7 @@ int do_record(int c)
{
char_u *p;
static int regname;
+ static bool changed_cmdheight = false;
yankreg_T *old_y_previous;
int retval;
@@ -906,6 +907,15 @@ int do_record(int c)
showmode();
regname = c;
retval = OK;
+
+ if (!ui_has_messages()) {
+ // Enable macro indicator temporarily
+ set_option_value("ch", 1L, NULL, 0);
+ update_screen(VALID);
+
+ changed_cmdheight = true;
+ }
+
apply_autocmds(EVENT_RECORDINGENTER, NULL, NULL, false, curbuf);
}
} else { // stop recording
@@ -951,6 +961,12 @@ int do_record(int c)
y_previous = old_y_previous;
}
+
+ if (changed_cmdheight) {
+ // Restore cmdheight
+ set_option_value("ch", 0L, NULL, 0);
+ redraw_all_later(CLEAR);
+ }
}
return retval;
}
@@ -2789,7 +2805,7 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append)
xfree(reg->y_array);
}
- if (message && (p_ch > 0 || ui_has(kUIMessages))) { // Display message about yank?
+ if (message) { // Display message about yank?
if (yank_type == kMTCharWise && yanklines == 1) {
yanklines = 0;
}
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index dcc84e3e6f..80f6f75fea 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -6142,10 +6142,6 @@ void unshowmode(bool force)
// Clear the mode message.
void clearmode(void)
{
- if (p_ch <= 0 && !ui_has(kUIMessages)) {
- return;
- }
-
const int save_msg_row = msg_row;
const int save_msg_col = msg_col;
@@ -6163,10 +6159,6 @@ void clearmode(void)
static void recording_mode(int attr)
{
- if (p_ch <= 0 && !ui_has(kUIMessages)) {
- return;
- }
-
msg_puts_attr(_("recording"), attr);
if (!shortmess(SHM_RECORDING)) {
char s[4];
@@ -6471,8 +6463,7 @@ int redrawing(void)
*/
int messaging(void)
{
- return !(p_lz && char_avail() && !KeyTyped)
- && (p_ch > 0 || ui_has(kUIMessages));
+ return !(p_lz && char_avail() && !KeyTyped) && ui_has_messages();
}
/// Show current status info in ruler and various other places
@@ -6509,7 +6500,7 @@ static void win_redr_ruler(win_T *wp, bool always)
bool is_stl_global = global_stl_height() > 0;
static bool did_show_ext_ruler = false;
- // If 'ruler' off or redrawing disabled, don't do anything
+ // If 'ruler' off, don't do anything
if (!p_ru) {
return;
}
@@ -6586,7 +6577,7 @@ static void win_redr_ruler(win_T *wp, bool always)
off = 0;
}
- if (!part_of_status && p_ch < 1 && !ui_has(kUIMessages)) {
+ if (!part_of_status && !ui_has_messages()) {
return;
}
diff --git a/src/nvim/testdir/test_ins_complete.vim b/src/nvim/testdir/test_ins_complete.vim
index 362c58aa31..179218e48a 100644
--- a/src/nvim/testdir/test_ins_complete.vim
+++ b/src/nvim/testdir/test_ins_complete.vim
@@ -346,7 +346,7 @@ func Test_CompleteDone_modify()
\ 'user_data': '',
\ }
let v:completed_item = value
- call assert_equal(v:completed_item, value)
+ call assert_equal(value, v:completed_item)
endfunc
func CompleteTest(findstart, query)
diff --git a/src/nvim/testdir/test_messages.vim b/src/nvim/testdir/test_messages.vim
index 2f9c562771..a02d23b409 100644
--- a/src/nvim/testdir/test_messages.vim
+++ b/src/nvim/testdir/test_messages.vim
@@ -316,4 +316,60 @@ func Test_fileinfo_after_echo()
call delete('b.txt')
endfunc
+func Test_cmdheight_zero()
+ set cmdheight=0
+ set showcmd
+ redraw!
+
+ echo 'test echo'
+ call assert_equal(116, screenchar(&lines, 1))
+ redraw!
+
+ echomsg 'test echomsg'
+ call assert_equal(116, screenchar(&lines, 1))
+ redraw!
+
+ call feedkeys(":ls\<CR>", "xt")
+ call assert_equal(':ls', Screenline(&lines - 1))
+ redraw!
+
+ let char = getchar(0)
+ call assert_match(char, 0)
+
+ " Check change/restore cmdheight when macro
+ call feedkeys("qa", "xt")
+ call assert_equal(1, &cmdheight)
+ call feedkeys("q", "xt")
+ call assert_equal(0, &cmdheight)
+
+ call setline(1, 'somestring')
+ call feedkeys("y", "n")
+ %s/somestring/otherstring/gc
+ call assert_equal('otherstring', getline(1))
+
+ call feedkeys("g\<C-g>", "xt")
+ call assert_match(
+ \ 'Col 1 of 11; Line 1 of 1; Word 1 of 1',
+ \ Screenline(&lines))
+
+ " Check split behavior
+ for i in range(1, 10)
+ split
+ endfor
+ only
+ call assert_equal(0, &cmdheight)
+
+ " Check that pressing ":" should not scroll a window
+ " Check for what patch 9.0.0115 fixes
+ botright 10new
+ call setline(1, range(12))
+ 7
+ call feedkeys(":\"\<C-R>=line('w0')\<CR>\<CR>", "xt")
+ call assert_equal('"1', @:)
+ bwipe!
+
+ set cmdheight&
+ set showcmd&
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_syn_attr.vim b/src/nvim/testdir/test_syn_attr.vim
index fa0b08fde5..88f9d0d84d 100644
--- a/src/nvim/testdir/test_syn_attr.vim
+++ b/src/nvim/testdir/test_syn_attr.vim
@@ -1,19 +1,39 @@
" Test syntax highlighting functions.
func Test_missing_attr()
- hi Mine cterm=italic
+ throw 'Skipped: use test/functional/legacy/syn_attr_spec.lua'
+
+ hi Mine term=bold cterm=italic
call assert_equal('Mine', synIDattr(hlID("Mine"), "name"))
+ call assert_equal('', synIDattr("Mine"->hlID(), "bg", 'term'))
+ call assert_equal('', synIDattr("Mine"->hlID(), "fg", 'term'))
+ call assert_equal('', synIDattr("Mine"->hlID(), "sp", 'term'))
+ call assert_equal('1', synIDattr(hlID("Mine"), "bold", 'term'))
call assert_equal('1', synIDattr(hlID("Mine"), "italic", 'cterm'))
- hi Mine cterm=inverse
+ hi Mine term=reverse cterm=inverse
+ call assert_equal('1', synIDattr(hlID("Mine"), "reverse", 'term'))
call assert_equal('1', synIDattr(hlID("Mine"), "inverse", 'cterm'))
- hi Mine cterm=standout gui=undercurl
+
+ hi Mine term=underline cterm=standout gui=undercurl
+ call assert_equal('1', synIDattr(hlID("Mine"), "underline", 'term'))
call assert_equal('1', synIDattr(hlID("Mine"), "standout", 'cterm'))
call assert_equal('1', synIDattr("Mine"->hlID(), "undercurl", 'gui'))
- hi Mine gui=strikethrough
+
+ hi Mine term=underdouble cterm=underdotted gui=underdashed
+ call assert_equal('1', synIDattr(hlID("Mine"), "underdouble", 'term'))
+ call assert_equal('1', synIDattr(hlID("Mine"), "underdotted", 'cterm'))
+ call assert_equal('1', synIDattr("Mine"->hlID(), "underdashed", 'gui'))
+
+ hi Mine term=nocombine gui=strikethrough
call assert_equal('1', synIDattr(hlID("Mine"), "strikethrough", 'gui'))
- hi Mine cterm=NONE gui=NONE
+ call assert_equal('1', synIDattr(hlID("Mine"), "nocombine", 'term'))
+ call assert_equal('', synIDattr(hlID("Mine"), "nocombine", 'gui'))
+ hi Mine term=NONE cterm=NONE gui=NONE
+ call assert_equal('', synIDattr(hlID("Mine"), "bold", 'term'))
call assert_equal('', synIDattr(hlID("Mine"), "italic", 'cterm'))
+ call assert_equal('', synIDattr(hlID("Mine"), "reverse", 'term'))
call assert_equal('', synIDattr(hlID("Mine"), "inverse", 'cterm'))
+ call assert_equal('', synIDattr(hlID("Mine"), "underline", 'term'))
call assert_equal('', synIDattr(hlID("Mine"), "standout", 'cterm'))
call assert_equal('', synIDattr(hlID("Mine"), "undercurl", 'gui'))
call assert_equal('', synIDattr(hlID("Mine"), "strikethrough", 'gui'))
diff --git a/src/nvim/testdir/test_window_cmd.vim b/src/nvim/testdir/test_window_cmd.vim
index 3bfff0a577..d96fc2d789 100644
--- a/src/nvim/testdir/test_window_cmd.vim
+++ b/src/nvim/testdir/test_window_cmd.vim
@@ -1390,11 +1390,9 @@ func Test_win_move_statusline()
call assert_equal(h0, winheight(0))
call assert_equal(1, &cmdheight)
endfor
- " Nvim supports cmdheight=0
+ " supports cmdheight=0
set cmdheight=0
call assert_true(win_move_statusline(0, 1))
- "call assert_equal(h0, winheight(0))
- "call assert_equal(1, &cmdheight)
call assert_equal(h0 + 1, winheight(0))
call assert_equal(0, &cmdheight)
set cmdheight&
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
index e958f02e32..4fcfee1192 100644
--- a/src/nvim/ui.c
+++ b/src/nvim/ui.c
@@ -612,6 +612,12 @@ bool ui_has(UIExtension ext)
return ui_ext[ext];
}
+/// Returns true if the UI has messages area.
+bool ui_has_messages(void)
+{
+ return p_ch > 0 || ui_has(kUIMessages);
+}
+
Array ui_array(void)
{
Array all_uis = ARRAY_DICT_INIT;
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 7225cfb9c7..ff147e22df 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -5555,7 +5555,6 @@ static void frame_setheight(frame_T *curfrp, int height)
}
if (curfrp->fr_parent == NULL) {
- // topframe: can only change the command line
if (height > ROWS_AVAIL) {
// If height is greater than the available space, try to create space for
// the frame by reducing 'cmdheight' if possible, while making sure
@@ -5877,7 +5876,7 @@ void win_setminheight(void)
// loop until there is a 'winminheight' that is possible
while (p_wmh > 0) {
const int room = Rows - (int)p_ch;
- const int needed = min_rows() - 1; // 1 was added for the cmdline
+ const int needed = min_rows();
if (room >= needed) {
break;
}
@@ -6307,7 +6306,8 @@ void win_set_inner_size(win_T *wp)
// There is no point in adjusting the scroll position when exiting. Some
// values might be invalid.
- if (!exiting) {
+ // Skip scroll_to_fraction() when 'cmdheight' was set to one from zero.
+ if (!exiting && !made_cmdheight_nonzero) {
scroll_to_fraction(wp, prev_height);
}
redraw_later(wp, NOT_VALID); // SOME_VALID??
@@ -6830,7 +6830,9 @@ int min_rows(void)
}
}
total += tabline_height() + global_stl_height();
- total += 1; // count the room for the command line
+ if (p_ch > 0) {
+ total += 1; // count the room for the command line
+ }
return total;
}