aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_getln.c6
-rw-r--r--src/nvim/menu.c12
-rw-r--r--src/nvim/ops.c26
-rw-r--r--src/nvim/screen.c37
-rw-r--r--src/nvim/syntax.c9
-rw-r--r--src/nvim/testdir/test_syntax.vim78
-rw-r--r--src/nvim/version.c6
7 files changed, 142 insertions, 32 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index fd7ad7a4b5..54e5bcb9ff 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -1863,9 +1863,13 @@ char *getcmdline_prompt(const char firstc, const char *const prompt,
ccline.input_fn = (firstc == '@');
ccline.highlight_callback = highlight_callback;
+ int msg_silent_saved = msg_silent;
+ msg_silent = 0;
+
char *const ret = (char *)getcmdline(firstc, 1L, 0);
restore_cmdline(&save_ccline);
+ msg_silent = msg_silent_saved;
// Restore msg_col, the prompt from input() may have changed it.
// But only if called recursively and the commandline is therefore being
// restored to an old one; if not, the input() prompt stays on the screen,
@@ -5714,6 +5718,7 @@ static int ex_window(void)
i = RedrawingDisabled;
RedrawingDisabled = 0;
+ int save_count = save_batch_count();
/*
* Call the main loop until <CR> or CTRL-C is typed.
@@ -5722,6 +5727,7 @@ static int ex_window(void)
normal_enter(true, false);
RedrawingDisabled = i;
+ restore_batch_count(save_count);
int save_KeyTyped = KeyTyped;
diff --git a/src/nvim/menu.c b/src/nvim/menu.c
index 0db250d111..88d968704b 100644
--- a/src/nvim/menu.c
+++ b/src/nvim/menu.c
@@ -682,6 +682,10 @@ static dict_T *menu_get_recursive(const vimmenu_T *menu, int modes)
tv_dict_add_str(dict, S_LEN("shortcut"), buf);
}
+ if (menu->actext) {
+ tv_dict_add_str(dict, S_LEN("actext"), (char *)menu->actext);
+ }
+
if (menu->modes & MENU_TIP_MODE && menu->strings[MENU_INDEX_TIP]) {
tv_dict_add_str(dict, S_LEN("tooltip"),
(char *)menu->strings[MENU_INDEX_TIP]);
@@ -695,11 +699,9 @@ static dict_T *menu_get_recursive(const vimmenu_T *menu, int modes)
for (int bit = 0; bit < MENU_MODES; bit++) {
if ((menu->modes & modes & (1 << bit)) != 0) {
dict_T *impl = tv_dict_alloc();
- if (*menu->strings[bit] == NUL) {
- tv_dict_add_str(impl, S_LEN("rhs"), (char *)"<Nop>");
- } else {
- tv_dict_add_str(impl, S_LEN("rhs"), (char *)menu->strings[bit]);
- }
+ tv_dict_add_allocated_str(impl, S_LEN("rhs"),
+ str2special_save((char *)menu->strings[bit],
+ false, false));
tv_dict_add_nr(impl, S_LEN("silent"), menu->silent[bit]);
tv_dict_add_nr(impl, S_LEN("enabled"),
(menu->enabled & (1 << bit)) ? 1 : 0);
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 99dc4670f1..e7bc20698b 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -5755,7 +5755,6 @@ void start_batch_changes(void)
return;
}
clipboard_delay_update = true;
- clipboard_needs_update = false;
}
/// Counterpart to start_batch_changes().
@@ -5767,12 +5766,37 @@ void end_batch_changes(void)
}
clipboard_delay_update = false;
if (clipboard_needs_update) {
+ // must be before, as set_clipboard will invoke
+ // start/end_batch_changes recursively
+ clipboard_needs_update = false;
// unnamed ("implicit" clipboard)
set_clipboard(NUL, y_previous);
+ }
+}
+
+int save_batch_count(void)
+{
+ int save_count = batch_change_count;
+ batch_change_count = 0;
+ clipboard_delay_update = false;
+ if (clipboard_needs_update) {
clipboard_needs_update = false;
+ // unnamed ("implicit" clipboard)
+ set_clipboard(NUL, y_previous);
}
+ return save_count;
}
+void restore_batch_count(int save_count)
+{
+ assert(batch_change_count == 0);
+ batch_change_count = save_count;
+ if (batch_change_count > 0) {
+ clipboard_delay_update = true;
+ }
+}
+
+
/// Check whether register is empty
static inline bool reg_empty(const yankreg_T *const reg)
FUNC_ATTR_PURE
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 5659f30f64..f5730cf70a 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -2202,7 +2202,6 @@ win_line (
colnr_T trailcol = MAXCOL; /* start of trailing spaces */
int need_showbreak = false; // overlong line, skip first x chars
int line_attr = 0; // attribute for the whole line
- int line_attr_low_priority = 0; // current line, lowest priority
matchitem_T *cur; // points to the match list
match_T *shl; // points to search_hl or a match
int shl_flag; // flag to indicate whether search_hl
@@ -2428,13 +2427,7 @@ win_line (
filler_lines = wp->w_topfill;
filler_todo = filler_lines;
- // 'cursorline' highlighting for the current window. Not when Visual mode is
- // active, because it's not clear what is selected then.
- if (wp->w_p_cul && lnum == wp->w_cursor.lnum
- && !(wp == curwin && VIsual_active)) {
- line_attr_low_priority = win_hl_attr(wp, HLF_CUL);
- }
-
+ // If this line has a sign with line highlighting set line_attr.
v = buf_getsigntype(wp->w_buffer, lnum, SIGN_LINEHL);
if (v != 0) {
line_attr = sign_get_attr((int)v, true);
@@ -2449,7 +2442,7 @@ win_line (
line_attr = hl_combine_attr(wp->w_hl_attr_normal, line_attr);
}
- if (line_attr_low_priority || line_attr) {
+ if (line_attr != 0) {
area_highlighting = true;
}
@@ -2671,6 +2664,20 @@ win_line (
cur = cur->next;
}
+ // Cursor line highlighting for 'cursorline' in the current window. Not
+ // when Visual mode is active, because it's not clear what is selected
+ // then.
+ if (wp->w_p_cul && lnum == wp->w_cursor.lnum
+ && !(wp == curwin && VIsual_active)) {
+ if (line_attr != 0 && !(State & INSERT) && bt_quickfix(wp->w_buffer)
+ && qf_current_entry(wp) == lnum) {
+ line_attr = hl_combine_attr(win_hl_attr(wp, HLF_CUL), line_attr);
+ } else {
+ line_attr = win_hl_attr(wp, HLF_CUL);
+ }
+ area_highlighting = true;
+ }
+
off = (unsigned)(current_ScreenLine - ScreenLines);
col = 0;
if (wp->w_p_rl) {
@@ -3589,9 +3596,7 @@ win_line (
// Display a '$' after the line or highlight an extra
// character if the line break is included.
// For a diff line the highlighting continues after the "$".
- if (diff_hlf == (hlf_T)0
- && line_attr == 0
- && line_attr_low_priority == 0) {
+ if (diff_hlf == (hlf_T)0 && line_attr == 0) {
// In virtualedit, visual selections may extend beyond end of line.
if (area_highlighting && virtual_active()
&& tocol != MAXCOL && vcol < tocol) {
@@ -3655,7 +3660,7 @@ win_line (
(col < wp->w_width))) {
c = ' ';
ptr--; // put it back at the NUL
- } else if ((diff_hlf != (hlf_T)0 || line_attr_low_priority || line_attr)
+ } else if ((diff_hlf != (hlf_T)0 || line_attr != 0)
&& (wp->w_p_rl
? (col >= 0)
: (col - boguscols < wp->w_width))) {
@@ -3667,8 +3672,7 @@ win_line (
did_line_attr++;
// don't do search HL for the rest of the line
- if ((line_attr_low_priority || line_attr)
- && char_attr == search_attr && col > 0) {
+ if (line_attr != 0 && char_attr == search_attr && col > 0) {
char_attr = line_attr;
}
if (diff_hlf == HLF_TXD) {
@@ -4037,9 +4041,6 @@ win_line (
}
}
- // Apply `line_attr_low_priority` now, so that everthing can override it.
- char_attr = hl_combine_attr(line_attr_low_priority, char_attr);
-
/*
* Store character to be displayed.
* Skip characters that are left of the screen for 'nowrap'.
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index 0224b28c2a..70bda42d83 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -5868,9 +5868,12 @@ static void syntime_report(void)
}
}
- /* sort on total time */
- qsort(ga.ga_data, (size_t)ga.ga_len, sizeof(time_entry_T),
- syn_compare_syntime);
+ // Sort on total time. Skip if there are no items to avoid passing NULL
+ // pointer to qsort().
+ if (ga.ga_len > 1) {
+ qsort(ga.ga_data, (size_t)ga.ga_len, sizeof(time_entry_T),
+ syn_compare_syntime);
+ }
MSG_PUTS_TITLE(_(
" TOTAL COUNT MATCH SLOWEST AVERAGE NAME PATTERN"));
diff --git a/src/nvim/testdir/test_syntax.vim b/src/nvim/testdir/test_syntax.vim
index 05e930d984..6c084dd2a7 100644
--- a/src/nvim/testdir/test_syntax.vim
+++ b/src/nvim/testdir/test_syntax.vim
@@ -50,7 +50,7 @@ func Test_syn_iskeyword()
setlocal isk-=_
call assert_equal('DLTD_BY', GetSyntaxItem('DLTD'))
/\<D\k\+\>/:norm! ygn
- let b2=@0
+ let b2 = @0
call assert_equal('DLTD', @0)
syn iskeyword clear
@@ -77,10 +77,84 @@ func Test_syntax_after_reload()
call delete('Xsomefile')
endfunc
+func Test_syntime()
+ if !has('profile')
+ return
+ endif
+
+ syntax on
+ syntime on
+ let a = execute('syntime report')
+ call assert_equal("\nNo Syntax items defined for this buffer", a)
+
+ view ../memfile_test.c
+ setfiletype cpp
+ redraw
+ let a = execute('syntime report')
+ call assert_match('^ TOTAL *COUNT *MATCH *SLOWEST *AVERAGE *NAME *PATTERN', a)
+ call assert_match(' \d*\.\d* \+[^0]\d* .* cppRawString ', a)
+ call assert_match(' \d*\.\d* \+[^0]\d* .* cppNumber ', a)
+
+ syntime off
+ syntime clear
+ let a = execute('syntime report')
+ call assert_match('^ TOTAL *COUNT *MATCH *SLOWEST *AVERAGE *NAME *PATTERN', a)
+ call assert_notmatch('.* cppRawString *', a)
+ call assert_notmatch('.* cppNumber*', a)
+ call assert_notmatch('[1-9]', a)
+
+ call assert_fails('syntime abc', 'E475')
+
+ syntax clear
+ let a = execute('syntime report')
+ call assert_equal("\nNo Syntax items defined for this buffer", a)
+
+ bd
+endfunc
+
+func Test_syntax_list()
+ syntax on
+ let a = execute('syntax list')
+ call assert_equal("\nNo Syntax items defined for this buffer", a)
+
+ view ../memfile_test.c
+ setfiletype c
+
+ let a = execute('syntax list')
+ call assert_match('cInclude*', a)
+ call assert_match('cDefine', a)
+
+ let a = execute('syntax list cDefine')
+ call assert_notmatch('cInclude*', a)
+ call assert_match('cDefine', a)
+ call assert_match(' links to Macro$', a)
+
+ call assert_fails('syntax list ABCD', 'E28:')
+ call assert_fails('syntax list @ABCD', 'E392:')
+
+ syntax clear
+ let a = execute('syntax list')
+ call assert_equal("\nNo Syntax items defined for this buffer", a)
+
+ bd
+endfunc
+
func Test_syntax_completion()
+ call feedkeys(":syn \<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"syn case clear cluster conceal enable include iskeyword keyword list manual match off on region reset spell sync', @:)
+
+ call feedkeys(":syn case \<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"syn case ignore match', @:)
+
call feedkeys(":syn spell \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"syn spell default notoplevel toplevel', @:)
call feedkeys(":syn sync \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"syn sync ccomment clear fromstart linebreaks= linecont lines= match maxlines= minlines= region', @:)
-endfunc
+
+ call feedkeys(":syn list \<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_match('^"syn list Boolean Character ', @:)
+
+ call feedkeys(":syn match \<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_match('^"syn match Boolean Character ', @:)
+endfunc \ No newline at end of file
diff --git a/src/nvim/version.c b/src/nvim/version.c
index 6729adaff3..635314352d 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -948,7 +948,7 @@ static const int included_patches[] = {
158,
157,
156,
- // 155,
+ 155,
// 154,
// 153,
// 152 NA
@@ -971,8 +971,8 @@ static const int included_patches[] = {
135,
134,
133,
- // 132,
- // 131,
+ 132,
+ 131,
// 130 NA
// 129 NA
128,