Mercurial > vim
comparison src/ex_getln.c @ 22872:5a7db84713dc v8.2.1983
patch 8.2.1983: ml_get error when using <Cmd> to open a terminal
Commit: https://github.com/vim/vim/commit/f4d61bc559f8cb6adc4880183a4fd216865c0c30
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Nov 14 14:22:28 2020 +0100
patch 8.2.1983: ml_get error when using <Cmd> to open a terminal
Problem: ml_get error when using <Cmd> to open a terminal.
Solution: If the window changed reset the incsearch state. (closes https://github.com/vim/vim/issues/7289)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 14 Nov 2020 14:30:03 +0100 |
parents | 6d50182e7e24 |
children | 5fbac68bda23 |
comparison
equal
deleted
inserted
replaced
22871:5f0f170bd19f | 22872:5a7db84713dc |
---|---|
140 | 140 |
141 // Struct to store the state of 'incsearch' highlighting. | 141 // Struct to store the state of 'incsearch' highlighting. |
142 typedef struct { | 142 typedef struct { |
143 pos_T search_start; // where 'incsearch' starts searching | 143 pos_T search_start; // where 'incsearch' starts searching |
144 pos_T save_cursor; | 144 pos_T save_cursor; |
145 int winid; // window where this state is valid | |
145 viewstate_T init_viewstate; | 146 viewstate_T init_viewstate; |
146 viewstate_T old_viewstate; | 147 viewstate_T old_viewstate; |
147 pos_T match_start; | 148 pos_T match_start; |
148 pos_T match_end; | 149 pos_T match_end; |
149 int did_incsearch; | 150 int did_incsearch; |
152 } incsearch_state_T; | 153 } incsearch_state_T; |
153 | 154 |
154 static void | 155 static void |
155 init_incsearch_state(incsearch_state_T *is_state) | 156 init_incsearch_state(incsearch_state_T *is_state) |
156 { | 157 { |
158 is_state->winid = curwin->w_id; | |
157 is_state->match_start = curwin->w_cursor; | 159 is_state->match_start = curwin->w_cursor; |
158 is_state->did_incsearch = FALSE; | 160 is_state->did_incsearch = FALSE; |
159 is_state->incsearch_postponed = FALSE; | 161 is_state->incsearch_postponed = FALSE; |
160 is_state->magic_save = p_magic; | 162 is_state->magic_save = p_magic; |
161 CLEAR_POS(&is_state->match_end); | 163 CLEAR_POS(&is_state->match_end); |
1701 // cause the command not to be executed. | 1703 // cause the command not to be executed. |
1702 | 1704 |
1703 // Trigger SafeState if nothing is pending. | 1705 // Trigger SafeState if nothing is pending. |
1704 may_trigger_safestate(xpc.xp_numfiles <= 0); | 1706 may_trigger_safestate(xpc.xp_numfiles <= 0); |
1705 | 1707 |
1706 cursorcmd(); // set the cursor on the right spot | |
1707 | |
1708 // Get a character. Ignore K_IGNORE and K_NOP, they should not do | 1708 // Get a character. Ignore K_IGNORE and K_NOP, they should not do |
1709 // anything, such as stop completion. | 1709 // anything, such as stop completion. |
1710 do | 1710 do |
1711 { | |
1712 cursorcmd(); // set the cursor on the right spot | |
1711 c = safe_vgetc(); | 1713 c = safe_vgetc(); |
1712 while (c == K_IGNORE || c == K_NOP); | 1714 } while (c == K_IGNORE || c == K_NOP); |
1713 | 1715 |
1714 if (c == K_COMMAND | 1716 if (c == K_COMMAND |
1715 && do_cmdline(NULL, getcmdkeycmd, NULL, DOCMD_NOWAIT) == OK) | 1717 && do_cmdline(NULL, getcmdkeycmd, NULL, DOCMD_NOWAIT) == OK) |
1716 goto cmdline_changed; | 1718 goto cmdline_changed; |
1717 | 1719 |
2325 if (!is_state.incsearch_postponed) | 2327 if (!is_state.incsearch_postponed) |
2326 continue; | 2328 continue; |
2327 #endif | 2329 #endif |
2328 | 2330 |
2329 cmdline_changed: | 2331 cmdline_changed: |
2332 #ifdef FEAT_SEARCH_EXTRA | |
2333 // If the window changed incremental search state is not valid. | |
2334 if (is_state.winid != curwin->w_id) | |
2335 init_incsearch_state(&is_state); | |
2336 #endif | |
2330 // Trigger CmdlineChanged autocommands. | 2337 // Trigger CmdlineChanged autocommands. |
2331 trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINECHANGED); | 2338 trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINECHANGED); |
2332 | 2339 |
2333 #ifdef FEAT_SEARCH_EXTRA | 2340 #ifdef FEAT_SEARCH_EXTRA |
2334 if (xpc.xp_context == EXPAND_NOTHING) | 2341 if (xpc.xp_context == EXPAND_NOTHING) |