diff options
-rw-r--r-- | runtime/doc/nvim_terminal_emulator.txt | 6 | ||||
-rw-r--r-- | runtime/doc/options.txt | 4 | ||||
-rw-r--r-- | runtime/doc/usr_41.txt | 2 | ||||
-rw-r--r-- | src/mpack/conv.c | 1 | ||||
-rw-r--r-- | src/mpack/lmpack.c | 2 | ||||
-rw-r--r-- | src/nvim/lua/treesitter.c | 10 | ||||
-rw-r--r-- | src/nvim/mouse.c | 12 | ||||
-rw-r--r-- | src/nvim/os/os_win_console.c | 26 | ||||
-rw-r--r-- | src/nvim/shada.c | 49 | ||||
-rw-r--r-- | src/nvim/terminal.c | 21 | ||||
-rw-r--r-- | src/nvim/tui/tui.c | 28 | ||||
-rw-r--r-- | src/nvim/undo.c | 2 | ||||
-rw-r--r-- | test/functional/lua/buffer_updates_spec.lua | 13 | ||||
-rw-r--r-- | test/functional/terminal/buffer_spec.lua | 20 | ||||
-rw-r--r-- | third-party/CMakeLists.txt | 4 |
15 files changed, 86 insertions, 114 deletions
diff --git a/runtime/doc/nvim_terminal_emulator.txt b/runtime/doc/nvim_terminal_emulator.txt index 5ad69d1122..e83b17f9a0 100644 --- a/runtime/doc/nvim_terminal_emulator.txt +++ b/runtime/doc/nvim_terminal_emulator.txt @@ -53,7 +53,7 @@ next key is sent unless it is <C-N>. Use <C-\><C-N> to return to normal-mode. Terminal-mode forces these local options: - 'nocursorline' + 'cursorlineopt' = number 'nocursorcolumn' 'scrolloff' = 0 'sidescrolloff' = 0 @@ -171,7 +171,7 @@ program window A terminal window for the executed program. When "run" is The current window is used to show the source code. When gdb pauses the source file location will be displayed, if possible. A sign is used to -highlight the current position, using highlight group debugPC. +highlight the current position, using highlight group debugPC. If the buffer in the current window is modified, another window will be opened to display the current gdb position. @@ -222,7 +222,7 @@ Put focus on the gdb window and type: > run Vim will start running in the program window. Put focus there and type: > :help gui -Gdb will run into the ex_help breakpoint. The source window now shows the +Gdb will run into the ex_help breakpoint. The source window now shows the ex_cmds.c file. A red "1 " marker will appear in the signcolumn where the breakpoint was set. The line where the debugger stopped is highlighted. You can now step through the program. You will see the highlighting move as the diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 85be6eddaa..981bdd09fc 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1409,9 +1409,9 @@ A jump table for the options with a short description can be found at |Q_op|. When this option is set it overrules 'shellslash' for completion: - When this option is set to "slash", a forward slash is used for path completion in insert mode. This is useful when editing HTML tag, or - Makefile with 'noshellslash' on Windows. + Makefile with 'noshellslash' on MS-Windows. - When this option is set to "backslash", backslash is used. This is - useful when editing a batch file with 'shellslash' set on Windows. + useful when editing a batch file with 'shellslash' set on MS-Windows. - When this option is empty, same character is used as for 'shellslash'. For Insert mode completion the buffer-local value is used. For diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index 5d70834ddc..c575dd9fd8 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -1804,7 +1804,7 @@ First of all you must choose a name for your plugin. The features provided by the plugin should be clear from its name. And it should be unlikely that someone else writes a plugin with the same name but which does something different. And please limit the name to 8 characters, to avoid problems on -old Windows systems. +old MS-Windows systems. A script that corrects typing mistakes could be called "typecorr.vim". We will use it here as an example. diff --git a/src/mpack/conv.c b/src/mpack/conv.c index 31297a8784..6bd446ca49 100644 --- a/src/mpack/conv.c +++ b/src/mpack/conv.c @@ -301,7 +301,6 @@ MPACK_API double mpack_unpack_number(mpack_token_t t) */ if (!hi) { assert(t.length <= 4); - hi = 0; lo = (~lo & (((mpack_uint32_t)1 << ((t.length * 8) - 1)) - 1)); } else { hi = ~hi; diff --git a/src/mpack/lmpack.c b/src/mpack/lmpack.c index 4b0e132a3a..2d6131d7cb 100644 --- a/src/mpack/lmpack.c +++ b/src/mpack/lmpack.c @@ -445,7 +445,6 @@ static int lmpack_unpacker_unpack_str(lua_State *L, Unpacker *unpacker, if (rv == MPACK_NOMEM) { unpacker->parser = lmpack_grow_parser(unpacker->parser); if (!unpacker->parser) { - unpacker->unpacking = 0; return luaL_error(L, "failed to grow Unpacker capacity"); } } @@ -799,7 +798,6 @@ static int lmpack_packer_pack(lua_State *L) if (result == MPACK_NOMEM) { packer->parser = lmpack_grow_parser(packer->parser); if (!packer->parser) { - packer->packing = 0; return luaL_error(L, "Failed to grow Packer capacity"); } } diff --git a/src/nvim/lua/treesitter.c b/src/nvim/lua/treesitter.c index 37929093e3..bd978cc8ab 100644 --- a/src/nvim/lua/treesitter.c +++ b/src/nvim/lua/treesitter.c @@ -30,6 +30,7 @@ typedef struct { TSQueryCursor *cursor; int predicated_match; + int max_match_id; } TSLua_cursor; #ifdef INCLUDE_GENERATED_DECLARATIONS @@ -1055,6 +1056,8 @@ static int query_next_match(lua_State *L) static int query_next_capture(lua_State *L) { + // Upvalues are: + // [ cursor, node, query, current_match ] TSLua_cursor *ud = lua_touserdata(L, lua_upvalueindex(1)); TSQueryCursor *cursor = ud->cursor; @@ -1078,9 +1081,13 @@ static int query_next_capture(lua_State *L) lua_pushinteger(L, capture.index+1); // [index] push_node(L, capture.node, lua_upvalueindex(2)); // [index, node] + // Now check if we need to run the predicates uint32_t n_pred; ts_query_predicates_for_pattern(query, match.pattern_index, &n_pred); - if (n_pred > 0 && capture_index == 0) { + + if (n_pred > 0 && (ud->max_match_id < (int)match.id)) { + ud->max_match_id = match.id; + lua_pushvalue(L, lua_upvalueindex(4)); // [index, node, match] set_match(L, &match, lua_upvalueindex(2)); lua_pushinteger(L, match.pattern_index+1); @@ -1127,6 +1134,7 @@ static int node_rawquery(lua_State *L) TSLua_cursor *ud = lua_newuserdata(L, sizeof(*ud)); // [udata] ud->cursor = cursor; ud->predicated_match = -1; + ud->max_match_id = -1; lua_getfield(L, LUA_REGISTRYINDEX, TS_META_QUERYCURSOR); lua_setmetatable(L, -2); // [udata] diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c index cd9f5fc83e..f02c000e82 100644 --- a/src/nvim/mouse.c +++ b/src/nvim/mouse.c @@ -682,8 +682,8 @@ static int mouse_adjust_click(win_T *wp, int row, int col) vcol = offset; -#define incr() nudge++; ptr_end += utfc_ptr2len(ptr_end) -#define decr() nudge--; ptr_end -= utfc_ptr2len(ptr_end) +#define INCR() nudge++; ptr_end += utfc_ptr2len(ptr_end) +#define DECR() nudge--; ptr_end -= utfc_ptr2len(ptr_end) while (ptr < ptr_end && *ptr != NUL) { cwidth = win_chartabsize(curwin, ptr, vcol); @@ -692,7 +692,7 @@ static int mouse_adjust_click(win_T *wp, int row, int col) // A tab will "absorb" any previous adjustments. cwidth = MIN(cwidth, nudge); while (cwidth > 0) { - decr(); + DECR(); cwidth--; } } @@ -700,20 +700,20 @@ static int mouse_adjust_click(win_T *wp, int row, int col) matchid = syn_get_concealed_id(wp, lnum, (colnr_T)(ptr - line)); if (matchid != 0) { if (wp->w_p_cole == 3) { - incr(); + INCR(); } else { if (!(row > 0 && ptr == ptr_row_offset) && (wp->w_p_cole == 1 || (wp->w_p_cole == 2 && (wp->w_p_lcs_chars.conceal != NUL || syn_get_sub_char() != NUL)))) { // At least one placeholder character will be displayed. - decr(); + DECR(); } prev_matchid = matchid; while (prev_matchid == matchid && *ptr != NUL) { - incr(); + INCR(); ptr += utfc_ptr2len(ptr); matchid = syn_get_concealed_id(wp, lnum, (colnr_T)(ptr - line)); } diff --git a/src/nvim/os/os_win_console.c b/src/nvim/os/os_win_console.c index 2c9cb699fc..18e2e02b81 100644 --- a/src/nvim/os/os_win_console.c +++ b/src/nvim/os/os_win_console.c @@ -46,29 +46,3 @@ void os_replace_stdout_and_stderr_to_conout(void) const int conerr_fd = _open_osfhandle((intptr_t)conout_handle, 0); assert(conerr_fd == STDERR_FILENO); } - -void os_set_vtp(bool enable) -{ - static TriState is_legacy = kNone; - if (is_legacy == kNone) { - uv_tty_vtermstate_t state; - uv_tty_get_vterm_state(&state); - is_legacy = (state == UV_TTY_UNSUPPORTED) ? kTrue : kFalse; - } - if (!is_legacy && !os_has_vti()) { - uv_tty_set_vterm_state(enable ? UV_TTY_SUPPORTED : UV_TTY_UNSUPPORTED); - } -} - -static bool os_has_vti(void) -{ - static TriState has_vti = kNone; - if (has_vti == kNone) { - HANDLE handle = (HANDLE)_get_osfhandle(input_global_fd()); - DWORD dwMode; - if (handle != INVALID_HANDLE_VALUE && GetConsoleMode(handle, &dwMode)) { - has_vti = !!(dwMode & ENABLE_VIRTUAL_TERMINAL_INPUT) ? kTrue : kFalse; - } - } - return has_vti == kTrue; -} diff --git a/src/nvim/shada.c b/src/nvim/shada.c index 2d65db8437..0cec28c4de 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -65,11 +65,6 @@ KHASH_SET_INIT_INT64(bufset) KHASH_MAP_INIT_STR(fnamebufs, buf_T *) KHASH_SET_INIT_STR(strset) -#define find_shada_parameter(...) \ - ((const char *)find_shada_parameter(__VA_ARGS__)) -#define path_try_shorten_fname(b) \ - ((char *)path_try_shorten_fname((char_u *)b)) - #define SEARCH_KEY_MAGIC "sm" #define SEARCH_KEY_SMARTCASE "sc" #define SEARCH_KEY_HAS_LINE_OFFSET "sl" @@ -609,20 +604,6 @@ static inline void hmll_insert(HMLList *const hmll, HMLListEntry *hmll_entry, co } } -/// Iterate over HMLList in backward direction -/// -/// @param hmll Pointer to the list. -/// @param cur_entry Name of the variable to iterate over, must be already -/// defined. -/// @param code Code to execute on each iteration. -/// -/// @return `for` cycle header (use `HMLL_FORALL(hmll, cur_entry) {body}`). -#define HMLL_ITER_BACK(hmll, cur_entry, code) \ - for (cur_entry = (hmll)->last; cur_entry != NULL; \ - cur_entry = cur_entry->prev) { \ - code \ - } - /// Free linked list /// /// @param[in] hmll List to free. @@ -966,11 +947,12 @@ static void hms_insert(HistoryMergerState *const hms_p, const ShadaEntry entry, } } HMLListEntry *insert_after; - HMLL_ITER_BACK(hmll, insert_after, { + // Iterate over HMLList in backward direction + for (insert_after = hmll->last; insert_after != NULL; insert_after = insert_after->prev) { if (insert_after->data.timestamp <= entry.timestamp) { break; } - }) + } hmll_insert(hmll, insert_after, entry, can_free_entry); } @@ -1346,7 +1328,8 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags) } case kSDItemBufferList: for (size_t i = 0; i < cur_entry.data.buffer_list.size; i++) { - char *const sfname = path_try_shorten_fname(cur_entry.data.buffer_list.buffers[i].fname); + char *const sfname = + (char *)path_try_shorten_fname((char_u *)cur_entry.data.buffer_list.buffers[i].fname); buf_T *const buf = buflist_new((char_u *)cur_entry.data.buffer_list.buffers[i].fname, (char_u *)sfname, 0, BLN_LISTED); @@ -1488,7 +1471,7 @@ static char *shada_filename(const char *file) if (p_shadafile != NULL && *p_shadafile != NUL) { file = p_shadafile; } else { - if ((file = find_shada_parameter('n')) == NULL || *file == NUL) { + if ((file = (char *)find_shada_parameter('n')) == NULL || *file == NUL) { file = shada_get_default_file(); } // XXX It used to be one level lower, so that whatever is in @@ -1508,14 +1491,6 @@ static char *shada_filename(const char *file) msgpack_pack_str(spacker, sizeof(s) - 1); \ msgpack_pack_str_body(spacker, s, sizeof(s) - 1); \ } while (0) -#define PACK_STRING(s) \ - do { \ - const String s_ = (s); \ - msgpack_pack_str(spacker, s_.size); \ - if (s_.size) { \ - msgpack_pack_str_body(spacker, s_.data, s_.size); \ - } \ - } while (0) #define PACK_BIN(s) \ do { \ const String s_ = (s); \ @@ -1796,7 +1771,11 @@ static ShaDaWriteResult shada_pack_entry(msgpack_packer *const packer, ShadaEntr case kSDItemHeader: msgpack_pack_map(spacker, entry.data.header.size); for (size_t i = 0; i < entry.data.header.size; i++) { - PACK_STRING(entry.data.header.items[i].key); + const String s = entry.data.header.items[i].key; + msgpack_pack_str(spacker, s.size); + if (s.size) { + msgpack_pack_str_body(spacker, s.data, s.size); + } const Object obj = entry.data.header.items[i].value; switch (obj.type) { case kObjectTypeString: @@ -1842,7 +1821,6 @@ shada_pack_entry_error: msgpack_sbuffer_destroy(&sbuf); return ret; } -#undef PACK_STRING /// Write single ShaDa entry and free it afterwards /// @@ -2943,7 +2921,6 @@ shada_write_exit: return ret; } -#undef IGNORE_BUF #undef PACK_STATIC_STR /// Write ShaDa file to a given location @@ -3410,8 +3387,7 @@ static ShaDaReadResult msgpack_read_uint64(ShaDaReadDef *const sd_reader, const sizeof(*un.data.via.map.ptr)); \ ad_ga.ga_len++; \ } -#define CONVERTED(str, len) (xmemdupz((str), (len))) -#define BIN_CONVERTED(b) CONVERTED(b.ptr, b.size) +#define BIN_CONVERTED(b) (xmemdupz((b.ptr), (b.size))) #define SET_ADDITIONAL_DATA(tgt, name) \ do { \ if (ad_ga.ga_len) { \ @@ -3968,7 +3944,6 @@ shada_read_next_item_error: goto shada_read_next_item_end; } #undef BIN_CONVERTED -#undef CONVERTED #undef CHECK_KEY #undef BOOLEAN_KEY #undef CONVERTED_STRING_KEY diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 6f19a9209e..07d668ba5b 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -358,11 +358,21 @@ void terminal_enter(void) // Disable these options in terminal-mode. They are nonsense because cursor is // placed at end of buffer to "follow" output. #11072 win_T *save_curwin = curwin; - int save_w_p_cul = curwin->w_p_cul; + bool save_w_p_cul = curwin->w_p_cul; + char_u *save_w_p_culopt = NULL; + char_u save_w_p_culopt_flags = curwin->w_p_culopt_flags; int save_w_p_cuc = curwin->w_p_cuc; long save_w_p_so = curwin->w_p_so; long save_w_p_siso = curwin->w_p_siso; - curwin->w_p_cul = false; + if (curwin->w_p_cul && curwin->w_p_culopt_flags & CULOPT_NBR) { + if (strcmp((char *)curwin->w_p_culopt, "number")) { + save_w_p_culopt = curwin->w_p_culopt; + curwin->w_p_culopt = (char_u *)xstrdup("number"); + } + curwin->w_p_culopt_flags = CULOPT_NBR; + } else { + curwin->w_p_cul = false; + } curwin->w_p_cuc = false; curwin->w_p_so = 0; curwin->w_p_siso = 0; @@ -386,9 +396,16 @@ void terminal_enter(void) if (save_curwin == curwin) { // save_curwin may be invalid (window closed)! curwin->w_p_cul = save_w_p_cul; + if (save_w_p_culopt) { + xfree(curwin->w_p_culopt); + curwin->w_p_culopt = save_w_p_culopt; + } + curwin->w_p_culopt_flags = save_w_p_culopt_flags; curwin->w_p_cuc = save_w_p_cuc; curwin->w_p_so = save_w_p_so; curwin->w_p_siso = save_w_p_siso; + } else if (save_w_p_culopt) { + xfree(save_w_p_culopt); } // draw the unfocused cursor diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 803ff23cea..612eaf6667 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1019,22 +1019,8 @@ static void tui_mouse_on(UI *ui) { TUIData *data = ui->data; if (!data->mouse_enabled) { -#ifdef WIN32 - // Windows versions with vtp(ENABLE_VIRTUAL_TERMINAL_PROCESSING) and - // no vti(ENABLE_VIRTUAL_TERMINAL_INPUT) will need to use mouse tracking of - // libuv. For this reason, vtp (vterm) state of libuv is temporarily - // disabled because the control sequence needs to be processed by libuv - // instead of Windows vtp. - // ref. https://docs.microsoft.com/en-us/windows/console/setconsolemode - flush_buf(ui); - os_set_vtp(false); -#endif unibi_out_ext(ui, data->unibi_ext.enable_mouse); data->mouse_enabled = true; -#ifdef WIN32 - flush_buf(ui); - os_set_vtp(true); -#endif } } @@ -1042,22 +1028,8 @@ static void tui_mouse_off(UI *ui) { TUIData *data = ui->data; if (data->mouse_enabled) { -#ifdef WIN32 - // Windows versions with vtp(ENABLE_VIRTUAL_TERMINAL_PROCESSING) and - // no vti(ENABLE_VIRTUAL_TERMINAL_INPUT) will need to use mouse tracking of - // libuv. For this reason, vtp (vterm) state of libuv is temporarily - // disabled because the control sequence needs to be processed by libuv - // instead of Windows vtp. - // ref. https://docs.microsoft.com/en-us/windows/console/setconsolemode - flush_buf(ui); - os_set_vtp(false); -#endif unibi_out_ext(ui, data->unibi_ext.disable_mouse); data->mouse_enabled = false; -#ifdef WIN32 - flush_buf(ui); - os_set_vtp(true); -#endif } } diff --git a/src/nvim/undo.c b/src/nvim/undo.c index d5857ff8b9..500845ec72 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -3085,6 +3085,8 @@ void u_undoline(void) oldp = u_save_line(curbuf->b_u_line_lnum); ml_replace(curbuf->b_u_line_lnum, curbuf->b_u_line_ptr, true); changed_bytes(curbuf->b_u_line_lnum, 0); + extmark_splice_cols(curbuf, (int)curbuf->b_u_line_lnum-1, 0, (colnr_T)STRLEN(oldp), + (colnr_T)STRLEN(curbuf->b_u_line_ptr), kExtmarkUndo); xfree(curbuf->b_u_line_ptr); curbuf->b_u_line_ptr = oldp; diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua index 073927bf22..aa92c36918 100644 --- a/test/functional/lua/buffer_updates_spec.lua +++ b/test/functional/lua/buffer_updates_spec.lua @@ -1050,6 +1050,19 @@ describe('lua: nvim_buf_attach on_bytes', function() } end) + it("sends updates on U", function() + feed("ggiAAA<cr>BBB") + feed("<esc>gg$a CCC") + + local check_events = setup_eventcheck(verify, nil) + + feed("ggU") + + check_events { + { "test1", "bytes", 1, 6, 0, 7, 7, 0, 0, 0, 0, 3, 3 }; + } + end) + teardown(function() os.remove "Xtest-reload" os.remove "Xtest-undofile" diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua index 103ae59b8e..5442724644 100644 --- a/test/functional/terminal/buffer_spec.lua +++ b/test/functional/terminal/buffer_spec.lua @@ -22,14 +22,28 @@ describe(':terminal buffer', function() it('terminal-mode forces various options', function() feed([[<C-\><C-N>]]) - command('setlocal cursorline cursorcolumn scrolloff=4 sidescrolloff=7') - eq({ 1, 1, 4, 7 }, eval('[&l:cursorline, &l:cursorcolumn, &l:scrolloff, &l:sidescrolloff]')) + command('setlocal cursorline cursorlineopt=both cursorcolumn scrolloff=4 sidescrolloff=7') + eq({ 'both', 1, 1, 4, 7 }, eval('[&l:cursorlineopt, &l:cursorline, &l:cursorcolumn, &l:scrolloff, &l:sidescrolloff]')) eq('n', eval('mode()')) -- Enter terminal-mode ("insert" mode in :terminal). feed('i') eq('t', eval('mode()')) - eq({ 0, 0, 0, 0 }, eval('[&l:cursorline, &l:cursorcolumn, &l:scrolloff, &l:sidescrolloff]')) + eq({ 'number', 1, 0, 0, 0 }, eval('[&l:cursorlineopt, &l:cursorline, &l:cursorcolumn, &l:scrolloff, &l:sidescrolloff]')) + end) + + it('terminal-mode does not change cursorlineopt if cursorline is disabled', function() + feed([[<C-\><C-N>]]) + command('setlocal nocursorline cursorlineopt=both') + feed('i') + eq({ 0, 'both' }, eval('[&l:cursorline, &l:cursorlineopt]')) + end) + + it('terminal-mode disables cursorline when cursorlineopt is only set to "line', function() + feed([[<C-\><C-N>]]) + command('setlocal cursorline cursorlineopt=line') + feed('i') + eq({ 0, 'line' }, eval('[&l:cursorline, &l:cursorlineopt]')) end) describe('when a new file is edited', function() diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index 12e429da24..29ff0daa8d 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -203,8 +203,8 @@ set(LIBICONV_SHA256 ccf536620a45458d26ba83887a983b96827001e92a13847b45e4925cc891 set(TREESITTER_C_URL https://github.com/tree-sitter/tree-sitter-c/archive/5aa0bbb.tar.gz) set(TREESITTER_C_SHA256 a5dcb37460d83002dfae7f9a208170ddbc9a047f231b9d6b75da7d36d707db2f) -set(TREESITTER_URL https://github.com/tree-sitter/tree-sitter/archive/v0.20.0.tar.gz) -set(TREESITTER_SHA256 4a8070b9de17c3b8096181fe8530320ab3e8cca685d8bee6a3e8d164b5fb47da) +set(TREESITTER_URL https://github.com/tree-sitter/tree-sitter/archive/7890a29db0b186b7b21a0a95d99fa6c562b8316b.tar.gz) +set(TREESITTER_SHA256 634006b0336a5eef1b07d2f80a4d4f8ac1522bf15759ec3e5dda0032a734fb19) if(USE_BUNDLED_UNIBILIUM) include(BuildUnibilium) |