aboutsummaryrefslogtreecommitdiff
path: root/src/nvim
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim')
-rw-r--r--src/nvim/buffer.c38
-rw-r--r--src/nvim/buffer_defs.h5
-rw-r--r--src/nvim/ex_cmds.lua12
-rw-r--r--src/nvim/fileio.c1
-rw-r--r--src/nvim/indent_c.c5
-rw-r--r--src/nvim/mbyte.c6
-rw-r--r--src/nvim/message.c21
-rw-r--r--src/nvim/ops.c18
-rw-r--r--src/nvim/os/env.c25
-rw-r--r--src/nvim/os/fs.c1
-rw-r--r--src/nvim/os/input.c10
-rw-r--r--src/nvim/quickfix.c78
-rw-r--r--src/nvim/testdir/test_quickfix.vim56
-rw-r--r--src/nvim/tui/tui.c18
-rw-r--r--src/nvim/version.c12
15 files changed, 226 insertions, 80 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 600cf575fc..26dbbe8bb5 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -282,6 +282,27 @@ bool buf_valid(buf_T *buf)
return false;
}
+// Map used to quickly lookup a buffer by its number.
+static PMap(handle_T) *buf_map = NULL;
+
+static void buf_hashtab_add(buf_T *buf)
+ FUNC_ATTR_NONNULL_ALL
+{
+ if (pmap_has(handle_T)(buf_map, buf->handle)) {
+ EMSG(_("E931: Buffer cannot be registered"));
+ } else {
+ pmap_put(handle_T)(buf_map, buf->handle, buf);
+ }
+}
+
+static void buf_hashtab_remove(buf_T *buf)
+ FUNC_ATTR_NONNULL_ALL
+{
+ if (pmap_has(handle_T)(buf_map, buf->handle)) {
+ pmap_del(handle_T)(buf_map, buf->handle);
+ }
+}
+
/// Close the link to a buffer.
///
/// @param win If not NULL, set b_last_cursor.
@@ -585,6 +606,7 @@ static void free_buffer(buf_T *buf)
free_buffer_stuff(buf, TRUE);
unref_var_dict(buf->b_vars);
aubuflocal_remove(buf);
+ buf_hashtab_remove(buf);
dict_unref(buf->additional_data);
clear_fmark(&buf->b_last_cursor);
clear_fmark(&buf->b_last_insert);
@@ -1369,7 +1391,10 @@ buf_T * buflist_new(char_u *ffname, char_u *sfname, linenr_T lnum, int flags)
{
buf_T *buf;
- fname_expand(curbuf, &ffname, &sfname); /* will allocate ffname */
+ if (top_file_num == 1) {
+ buf_map = pmap_new(handle_T)();
+ }
+ fname_expand(curbuf, &ffname, &sfname); // will allocate ffname
/*
* If file name already exists in the list, update the entry.
@@ -1493,6 +1518,7 @@ buf_T * buflist_new(char_u *ffname, char_u *sfname, linenr_T lnum, int flags)
}
top_file_num = 1;
}
+ buf_hashtab_add(buf);
/*
* Always copy the options from the current buffer.
@@ -2002,19 +2028,15 @@ static char_u *fname_match(regmatch_T *rmp, char_u *name, bool ignore_case)
return match;
}
-/*
- * find file in buffer list by number
- */
+/// Find a file in the buffer list by buffer number.
buf_T *buflist_findnr(int nr)
{
if (nr == 0) {
nr = curwin->w_alt_fnum;
}
- FOR_ALL_BUFFERS(buf) {
- if (buf->b_fnum == nr) {
- return buf;
- }
+ if (pmap_has(handle_T)(buf_map, (handle_T)nr)) {
+ return pmap_get(handle_T)(buf_map, (handle_T)nr);
}
return NULL;
}
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h
index 2b66a07f48..29f4dfe4fb 100644
--- a/src/nvim/buffer_defs.h
+++ b/src/nvim/buffer_defs.h
@@ -454,6 +454,9 @@ typedef struct {
} synblock_T;
+#define BUF_HAS_QF_ENTRY 1
+#define BUF_HAS_LL_ENTRY 2
+
/*
* buffer: structure that holds information about one file
*
@@ -611,7 +614,7 @@ struct file_buffer {
int b_p_bomb; ///< 'bomb'
char_u *b_p_bh; ///< 'bufhidden'
char_u *b_p_bt; ///< 'buftype'
- bool b_has_qf_entry; ///< quickfix exists for buffer
+ int b_has_qf_entry; ///< quickfix exists for buffer
int b_p_bl; ///< 'buflisted'
int b_p_cin; ///< 'cindent'
char_u *b_p_cino; ///< 'cinoptions'
diff --git a/src/nvim/ex_cmds.lua b/src/nvim/ex_cmds.lua
index 88095602ba..5f81306fc1 100644
--- a/src/nvim/ex_cmds.lua
+++ b/src/nvim/ex_cmds.lua
@@ -462,6 +462,12 @@ return {
func='ex_checktime',
},
{
+ command='chistory',
+ flags=bit.bor(TRLBAR),
+ addr_type=ADDR_LINES,
+ func='qf_history',
+ },
+ {
command='clist',
flags=bit.bor(BANG, EXTRA, TRLBAR, CMDWIN),
addr_type=ADDR_LINES,
@@ -1400,6 +1406,12 @@ return {
func='ex_helpgrep',
},
{
+ command='lhistory',
+ flags=bit.bor(TRLBAR),
+ addr_type=ADDR_LINES,
+ func='qf_history',
+ },
+ {
command='ll',
flags=bit.bor(RANGE, NOTADR, COUNT, TRLBAR, BANG),
addr_type=ADDR_LINES,
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 13329d771b..12206c1680 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -1882,6 +1882,7 @@ failed:
xfree(keep_msg);
keep_msg = NULL;
+ p = NULL;
msg_scrolled_ign = TRUE;
if (!read_stdin && !read_buffer) {
diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c
index 6f03cf6037..7b758b4dac 100644
--- a/src/nvim/indent_c.c
+++ b/src/nvim/indent_c.c
@@ -173,9 +173,8 @@ static char_u *skip_string(char_u *p)
char_u *delim = p + 2;
char_u *paren = vim_strchr(delim, '(');
- if (paren != NULL)
- {
- long delim_len = paren - delim;
+ if (paren != NULL) {
+ ptrdiff_t delim_len = paren - delim;
for (p += 3; *p; ++p)
if (p[0] == ')' && STRNCMP(p + 1, delim, delim_len) == 0
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c
index ec4969d4f6..c855d68605 100644
--- a/src/nvim/mbyte.c
+++ b/src/nvim/mbyte.c
@@ -1484,6 +1484,9 @@ int utf8_to_utf16(const char *str, WCHAR **strw)
(WCHAR *)pos,
wchar_len);
assert(r == wchar_len);
+ if (r != wchar_len) {
+ EMSG2("MultiByteToWideChar failed: %d", r);
+ }
*strw = (WCHAR *)pos;
return 0;
@@ -1519,6 +1522,9 @@ int utf16_to_utf8(const WCHAR *strw, char **str)
NULL,
NULL);
assert(r == utf8_len);
+ if (r != utf8_len) {
+ EMSG2("WideCharToMultiByte failed: %d", r);
+ }
*str = pos;
return 0;
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 2f8feda6ec..749fa8a706 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -297,8 +297,22 @@ void trunc_string(char_u *s, char_u *buf, int room, int buflen)
len += n;
}
- /* Set the middle and copy the last part. */
- if (e + 3 < buflen) {
+ if (i <= e + 3) {
+ // text fits without truncating
+ if (s != buf) {
+ len = STRLEN(s);
+ if (len >= buflen) {
+ len = buflen - 1;
+ }
+ len = len - e + 1;
+ if (len < 1) {
+ buf[e - 1] = NUL;
+ } else {
+ memmove(buf + e, s + e, len);
+ }
+ }
+ } else if (e + 3 < buflen) {
+ // set the middle and copy the last part
memmove(buf + e, "...", (size_t)3);
len = (int)STRLEN(s + i) + 1;
if (len >= buflen - e - 3)
@@ -306,7 +320,8 @@ void trunc_string(char_u *s, char_u *buf, int room, int buflen)
memmove(buf + e + 3, s + i, len);
buf[e + 3 + len - 1] = NUL;
} else {
- buf[e - 1] = NUL; /* make sure it is truncated */
+ // can't fit in the "...", just truncate it
+ buf[e - 1] = NUL;
}
}
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 645dcc0865..9a01891483 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -2643,8 +2643,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
char command_start_char = non_linewise_vis ? 'c' :
(flags & PUT_LINE ? 'i' : (dir == FORWARD ? 'a' : 'i'));
- // To avoid being the affect of 'autoindent' on linewise puts, we create a
- // new line with `:put _`.
+ // To avoid 'autoindent' on linewise puts, create a new line with `:put _`.
if (flags & PUT_LINE) {
do_put('_', NULL, dir, 1, PUT_LINE);
}
@@ -2668,6 +2667,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
} else {
(void)stuff_inserted(command_start_char, count, false);
}
+
// Putting the text is done later, so can't move the cursor to the next
// character. Simulate it with motion commands after the insert.
if (flags & PUT_CURSEND) {
@@ -2689,17 +2689,15 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
// incremented instead of curwin->w_cursor.col.
char_u *cursor_pos = get_cursor_pos_ptr();
bool one_past_line = (*cursor_pos == NUL);
- bool end_of_line = false;
+ bool eol = false;
if (!one_past_line) {
- end_of_line = (*(cursor_pos + mb_ptr2len(cursor_pos)) == NUL);
+ eol = (*(cursor_pos + mb_ptr2len(cursor_pos)) == NUL);
}
- bool virtualedit_allows = (ve_flags == VE_ALL
- || ve_flags == VE_ONEMORE);
- bool end_of_file = (
- (curbuf->b_ml.ml_line_count == curwin->w_cursor.lnum)
- && one_past_line);
- if (virtualedit_allows || !(end_of_line || end_of_file)) {
+ bool ve_allows = (ve_flags == VE_ALL || ve_flags == VE_ONEMORE);
+ bool eof = curbuf->b_ml.ml_line_count == curwin->w_cursor.lnum
+ && one_past_line;
+ if (ve_allows || !(eol || eof)) {
stuffcharReadbuff('l');
}
}
diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c
index 47d541c6a7..109b5c7175 100644
--- a/src/nvim/os/env.c
+++ b/src/nvim/os/env.c
@@ -226,25 +226,24 @@ char_u *expand_env_save_opt(char_u *src, bool one)
/// "~/" is also expanded, using $HOME. For Unix "~user/" is expanded.
/// Skips over "\ ", "\~" and "\$" (not for Win32 though).
/// If anything fails no expansion is done and dst equals src.
-/// @param src Input string e.g. "$HOME/vim.hlp"
-/// @param dst Where to put the result
-/// @param dstlen Maximum length of the result
+///
+/// @param src Input string e.g. "$HOME/vim.hlp"
+/// @param dst[out] Where to put the result
+/// @param dstlen Maximum length of the result
void expand_env(char_u *src, char_u *dst, int dstlen)
{
expand_env_esc(src, dst, dstlen, false, false, NULL);
}
/// Expand environment variable with path name and escaping.
-/// "~/" is also expanded, using $HOME. For Unix "~user/" is expanded.
-/// Skips over "\ ", "\~" and "\$" (not for Win32 though).
-/// If anything fails no expansion is done and dst equals src.
-/// prefix recognize the start of a new name, for '~' expansion.
-/// @param srcp Input string e.g. "$HOME/vim.hlp"
-/// @param dst Where to put the result
-/// @param dstlen Maximum length of the result
-/// @param esc Should we escape spaces in expanded variables?
-/// @param one Should we expand more than one '~'?
-/// @param prefix Common prefix for paths, can be NULL
+/// @see expand_env
+///
+/// @param srcp Input string e.g. "$HOME/vim.hlp"
+/// @param dst[out] Where to put the result
+/// @param dstlen Maximum length of the result
+/// @param esc Escape spaces in expanded variables
+/// @param one `srcp` is a single filename
+/// @param prefix Start again after this (can be NULL)
void expand_env_esc(char_u *restrict srcp,
char_u *restrict dst,
int dstlen,
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c
index 4aa727733e..30e08ac129 100644
--- a/src/nvim/os/fs.c
+++ b/src/nvim/os/fs.c
@@ -939,7 +939,6 @@ char_u * os_resolve_shortcut(char_u *fname)
OLECHAR wsz[MAX_PATH];
char_u *rfname = NULL;
int len;
- int conversion_result;
IShellLinkW *pslw = NULL;
WIN32_FIND_DATAW ffdw;
diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c
index b60a7eed36..f264a26939 100644
--- a/src/nvim/os/input.c
+++ b/src/nvim/os/input.c
@@ -170,12 +170,13 @@ bool os_isatty(int fd)
size_t input_enqueue(String keys)
{
- char *ptr = keys.data, *end = ptr + keys.size;
+ char *ptr = keys.data;
+ char *end = ptr + keys.size;
while (rbuffer_space(input_buffer) >= 6 && ptr < end) {
uint8_t buf[6] = { 0 };
- unsigned int new_size = trans_special((const uint8_t **)&ptr, keys.size,
- buf, true);
+ unsigned int new_size
+ = trans_special((const uint8_t **)&ptr, (size_t)(end - ptr), buf, true);
if (new_size) {
new_size = handle_mouse_event(&ptr, buf, new_size);
@@ -185,8 +186,7 @@ size_t input_enqueue(String keys)
if (*ptr == '<') {
char *old_ptr = ptr;
- // Invalid or incomplete key sequence, skip until the next '>' or until
- // *end
+ // Invalid or incomplete key sequence, skip until the next '>' or *end.
do {
ptr++;
} while (ptr < end && *ptr != '>');
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index 33a84660c1..19287ecffb 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -1105,7 +1105,8 @@ static int qf_add_entry(qf_info_T *qi, char_u *dir, char_u *fname, int bufnum,
qfp->qf_fnum = bufnum;
if (buf != NULL) {
- buf->b_has_qf_entry = true;
+ buf->b_has_qf_entry |=
+ (qi == &ql_info) ? BUF_HAS_QF_ENTRY : BUF_HAS_LL_ENTRY;
}
} else {
qfp->qf_fnum = qf_get_fnum(qi, dir, fname);
@@ -1282,7 +1283,7 @@ void copy_loclist(win_T *from, win_T *to)
to->w_llist->qf_curlist = qi->qf_curlist; /* current list */
}
-// Get buffer number for file "dir.name".
+// Get buffer number for file "directory.fname".
// Also sets the b_has_qf_entry flag.
static int qf_get_fnum(qf_info_T *qi, char_u *directory, char_u *fname)
{
@@ -1322,7 +1323,8 @@ static int qf_get_fnum(qf_info_T *qi, char_u *directory, char_u *fname)
if (buf == NULL) {
return 0;
}
- buf->b_has_qf_entry = true;
+ buf->b_has_qf_entry =
+ (qi == &ql_info) ? BUF_HAS_QF_ENTRY : BUF_HAS_LL_ENTRY;
return buf->b_fnum;
}
@@ -2105,6 +2107,31 @@ static void qf_fmt_text(char_u *text, char_u *buf, int bufsize)
buf[i] = NUL;
}
+static void qf_msg(qf_info_T *qi, int which, char *lead)
+{
+ char *title = (char *)qi->qf_lists[which].qf_title;
+ int count = qi->qf_lists[which].qf_count;
+ char_u buf[IOSIZE];
+
+ vim_snprintf((char *)buf, IOSIZE, _("%serror list %d of %d; %d errors "),
+ lead,
+ which + 1,
+ qi->qf_listcount,
+ count);
+
+ if (title != NULL) {
+ size_t len = STRLEN(buf);
+
+ if (len < 34) {
+ memset(buf + len, ' ', 34 - len);
+ buf[34] = NUL;
+ }
+ vim_strcat(buf, (char_u *)title, IOSIZE);
+ }
+ trunc_string(buf, buf, (int)Columns - 1, IOSIZE);
+ msg(buf);
+}
+
/*
* ":colder [count]": Up in the quickfix stack.
* ":cnewer [count]": Down in the quickfix stack.
@@ -2145,15 +2172,26 @@ void qf_age(exarg_T *eap)
++qi->qf_curlist;
}
}
- qf_msg(qi);
+ qf_msg(qi, qi->qf_curlist, "");
+ qf_update_buffer(qi, NULL);
}
-static void qf_msg(qf_info_T *qi)
+void qf_history(exarg_T *eap)
{
- smsg(_("error list %d of %d; %d errors"),
- qi->qf_curlist + 1, qi->qf_listcount,
- qi->qf_lists[qi->qf_curlist].qf_count);
- qf_update_buffer(qi, NULL);
+ qf_info_T *qi = &ql_info;
+ int i;
+
+ if (eap->cmdidx == CMD_lhistory) {
+ qi = GET_LOC_LIST(curwin);
+ }
+ if (qi == NULL || (qi->qf_listcount == 0
+ && qi->qf_lists[qi->qf_curlist].qf_count == 0)) {
+ MSG(_("No entries"));
+ } else {
+ for (i = 0; i < qi->qf_listcount; i++) {
+ qf_msg(qi, i, i == qi->qf_curlist ? "> " : " ");
+ }
+ }
}
/*
@@ -2203,8 +2241,9 @@ void qf_mark_adjust(win_T *wp, linenr_T line1, linenr_T line2, long amount, long
int idx;
qf_info_T *qi = &ql_info;
bool found_one = false;
+ int buf_has_flag = wp == NULL ? BUF_HAS_QF_ENTRY : BUF_HAS_LL_ENTRY;
- if (!curbuf->b_has_qf_entry) {
+ if (!(curbuf->b_has_qf_entry & buf_has_flag)) {
return;
}
if (wp != NULL) {
@@ -2231,7 +2270,7 @@ void qf_mark_adjust(win_T *wp, linenr_T line1, linenr_T line2, long amount, long
}
if (!found_one) {
- curbuf->b_has_qf_entry = false;
+ curbuf->b_has_qf_entry &= ~buf_has_flag;
}
}
@@ -3451,10 +3490,13 @@ void ex_vimgrep(exarg_T *eap)
col = 0;
while (vim_regexec_multi(&regmatch, curwin, buf, lnum,
col, NULL) > 0) {
+ // Pass the buffer number so that it gets used even for a
+ // dummy buffer, unless duplicate_name is set, then the
+ // buffer will be wiped out below.
if (qf_add_entry(qi,
NULL, // dir
fname,
- 0,
+ duplicate_name ? 0 : buf->b_fnum,
ml_get_buf(buf,
regmatch.startpos[0].lnum + lnum, false),
regmatch.startpos[0].lnum + lnum,
@@ -3508,17 +3550,23 @@ void ex_vimgrep(exarg_T *eap)
buf = NULL;
} else if (buf != first_match_buf || (flags & VGR_NOJUMP)) {
unload_dummy_buffer(buf, dirname_start);
+ // Keeping the buffer, remove the dummy flag.
+ buf->b_flags &= ~BF_DUMMY;
buf = NULL;
}
}
if (buf != NULL) {
- /* If the buffer is still loaded we need to use the
- * directory we jumped to below. */
+ // Keeping the buffer, remove the dummy flag.
+ buf->b_flags &= ~BF_DUMMY;
+
+ // If the buffer is still loaded we need to use the
+ // directory we jumped to below.
if (buf == first_match_buf
&& target_dir == NULL
- && STRCMP(dirname_start, dirname_now) != 0)
+ && STRCMP(dirname_start, dirname_now) != 0) {
target_dir = vim_strsave(dirname_now);
+ }
/* The buffer is still loaded, the Filetype autocommands
* need to be done now, in that buffer. And the modelines
diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim
index f30902b915..7464a11abd 100644
--- a/src/nvim/testdir/test_quickfix.vim
+++ b/src/nvim/testdir/test_quickfix.vim
@@ -1299,13 +1299,14 @@ function! Xadjust_qflnum(cchar)
enew | only
- call s:create_test_file('Xqftestfile')
- edit Xqftestfile
+ let fname = 'Xqftestfile' . a:cchar
+ call s:create_test_file(fname)
+ exe 'edit ' . fname
- Xgetexpr ['Xqftestfile:5:Line5',
- \ 'Xqftestfile:10:Line10',
- \ 'Xqftestfile:15:Line15',
- \ 'Xqftestfile:20:Line20']
+ Xgetexpr [fname . ':5:Line5',
+ \ fname . ':10:Line10',
+ \ fname . ':15:Line15',
+ \ fname . ':20:Line20']
6,14delete
call append(6, ['Buffer', 'Window'])
@@ -1317,11 +1318,13 @@ function! Xadjust_qflnum(cchar)
call assert_equal(13, l[3].lnum)
enew!
- call delete('Xqftestfile')
+ call delete(fname)
endfunction
function! Test_adjust_lnum()
+ call setloclist(0, [])
call Xadjust_qflnum('c')
+ call setqflist([])
call Xadjust_qflnum('l')
endfunction
@@ -1420,3 +1423,42 @@ function Test_cbottom()
call XbottomTests('c')
call XbottomTests('l')
endfunction
+
+function HistoryTest(cchar)
+ call s:setup_commands(a:cchar)
+
+ call assert_fails(a:cchar . 'older 99', 'E380:')
+ " clear all lists after the first one, then replace the first one.
+ call g:Xsetlist([])
+ Xolder
+ let entry = {'filename': 'foo', 'lnum': 42}
+ call g:Xsetlist([entry], 'r')
+ call g:Xsetlist([entry, entry])
+ call g:Xsetlist([entry, entry, entry])
+ let res = split(execute(a:cchar . 'hist'), "\n")
+ call assert_equal(3, len(res))
+ let common = 'errors :set' . (a:cchar == 'c' ? 'qf' : 'loc') . 'list()'
+ call assert_equal(' error list 1 of 3; 1 ' . common, res[0])
+ call assert_equal(' error list 2 of 3; 2 ' . common, res[1])
+ call assert_equal('> error list 3 of 3; 3 ' . common, res[2])
+endfunc
+
+func Test_history()
+ call HistoryTest('c')
+ call HistoryTest('l')
+endfunc
+
+func Test_duplicate_buf()
+ " make sure we can get the highest buffer number
+ edit DoesNotExist
+ edit DoesNotExist2
+ let last_buffer = bufnr("$")
+
+ " make sure only one buffer is created
+ call writefile(['this one', 'that one'], 'Xgrepthis')
+ vimgrep one Xgrepthis
+ vimgrep one Xgrepthis
+ call assert_equal(last_buffer + 1, bufnr("$"))
+
+ call delete('Xgrepthis')
+endfunc
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index 74187e07c0..342c68818d 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -844,7 +844,7 @@ static void fix_terminfo(TUIData *data)
}
if (STARTS_WITH(term, "xterm") || STARTS_WITH(term, "rxvt")) {
- unibi_set_if_empty(ut, unibi_cursor_normal, "\x1b[?12l\x1b[?25h");
+ unibi_set_if_empty(ut, unibi_cursor_normal, "\x1b[?25h");
unibi_set_if_empty(ut, unibi_cursor_invisible, "\x1b[?25l");
unibi_set_if_empty(ut, unibi_flash_screen, "\x1b[?5h$<100/>\x1b[?5l");
unibi_set_if_empty(ut, unibi_exit_attribute_mode, "\x1b(B\x1b[m");
@@ -877,9 +877,11 @@ static void fix_terminfo(TUIData *data)
unibi_set_str(ut, unibi_set_a_background, XTERM_SETAB);
}
- if (os_getenv("NVIM_TUI_ENABLE_CURSOR_SHAPE") == NULL) {
+ const char * env_cusr_shape = os_getenv("NVIM_TUI_ENABLE_CURSOR_SHAPE");
+ if (env_cusr_shape && strncmp(env_cusr_shape, "0", 1) == 0) {
goto end;
}
+ bool cusr_blink = env_cusr_shape && strncmp(env_cusr_shape, "2", 1) == 0;
#define TMUX_WRAP(seq) (inside_tmux ? "\x1bPtmux;\x1b" seq "\x1b\\" : seq)
// Support changing cursor shape on some popular terminals.
@@ -891,22 +893,22 @@ static void fix_terminfo(TUIData *data)
// Konsole uses a proprietary escape code to set the cursor shape
// and does not support DECSCUSR.
data->unibi_ext.set_cursor_shape_bar = (int)unibi_add_ext_str(ut, NULL,
- TMUX_WRAP("\x1b]50;CursorShape=1;BlinkingCursorEnabled=1\x07"));
+ TMUX_WRAP("\x1b]50;CursorShape=1\x07"));
data->unibi_ext.set_cursor_shape_ul = (int)unibi_add_ext_str(ut, NULL,
- TMUX_WRAP("\x1b]50;CursorShape=2;BlinkingCursorEnabled=1\x07"));
+ TMUX_WRAP("\x1b]50;CursorShape=2\x07"));
data->unibi_ext.set_cursor_shape_block = (int)unibi_add_ext_str(ut, NULL,
- TMUX_WRAP("\x1b]50;CursorShape=0;BlinkingCursorEnabled=0\x07"));
+ TMUX_WRAP("\x1b]50;CursorShape=0\x07"));
} else if (!vte_version || atoi(vte_version) >= 3900) {
// Assume that the terminal supports DECSCUSR unless it is an
// old VTE based terminal. This should not get wrapped for tmux,
// which will handle it via its Ss/Se terminfo extension - usually
// according to its terminal-overrides.
data->unibi_ext.set_cursor_shape_bar =
- (int)unibi_add_ext_str(ut, NULL, "\x1b[5 q");
+ (int)unibi_add_ext_str(ut, NULL, cusr_blink ? "\x1b[5 q" : "\x1b[6 q");
data->unibi_ext.set_cursor_shape_ul =
- (int)unibi_add_ext_str(ut, NULL, "\x1b[3 q");
+ (int)unibi_add_ext_str(ut, NULL, cusr_blink ? "\x1b[3 q" : "\x1b[4 q");
data->unibi_ext.set_cursor_shape_block =
- (int)unibi_add_ext_str(ut, NULL, "\x1b[2 q");
+ (int)unibi_add_ext_str(ut, NULL, cusr_blink ? "\x1b[1 q" : "\x1b[2 q");
}
end:
diff --git a/src/nvim/version.c b/src/nvim/version.c
index 3dfc32fc6d..3d81788a7e 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -359,7 +359,7 @@ static int included_patches[] = {
// 2084,
// 2083,
// 2082,
- // 2081,
+ 2081,
// 2080,
// 2079 NA
// 2078 NA
@@ -373,10 +373,10 @@ static int included_patches[] = {
// 2070 NA
// 2069,
// 2068,
- // 2067,
+ 2067,
2066,
2065,
- // 2064,
+ 2064,
// 2063 NA
2062,
// 2061,
@@ -390,8 +390,8 @@ static int included_patches[] = {
// 2053 NA
// 2052 NA
// 2051,
- // 2050,
- // 2049,
+ 2050,
+ 2049,
// 2048 NA
// 2047,
// 2046,
@@ -404,7 +404,7 @@ static int included_patches[] = {
// 2039 NA
// 2038 NA
// 2037 NA
- // 2036,
+ 2036,
// 2035 NA
// 2034 NA
2033,