comparison src/ex_docmd.c @ 12521:718787498836 v8.0.1139

patch 8.0.1139: using window toolbar changes state commit https://github.com/vim/vim/commit/a21a6a9ade7bec3a07992d4d900d4ce82eeb8a29 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Sep 23 16:33:50 2017 +0200 patch 8.0.1139: using window toolbar changes state Problem: Using window toolbar changes state. Solution: Always execute window toolbar actions in Normal mode.
author Christian Brabandt <cb@256bit.org>
date Sat, 23 Sep 2017 16:45:05 +0200
parents 972ea22c946f
children 241fbf588b95
comparison
equal deleted inserted replaced
12520:983f47a69df0 12521:718787498836
10105 validate_cursor(); 10105 validate_cursor();
10106 update_curswant(); 10106 update_curswant();
10107 } 10107 }
10108 10108
10109 /* 10109 /*
10110 * Save the current State and go to Normal mode.
10111 * Return TRUE if the typeahead could be saved.
10112 */
10113 int
10114 save_current_state(save_state_T *sst)
10115 {
10116 sst->save_msg_scroll = msg_scroll;
10117 sst->save_restart_edit = restart_edit;
10118 sst->save_msg_didout = msg_didout;
10119 sst->save_State = State;
10120 sst->save_insertmode = p_im;
10121 sst->save_finish_op = finish_op;
10122 sst->save_opcount = opcount;
10123
10124 msg_scroll = FALSE; /* no msg scrolling in Normal mode */
10125 restart_edit = 0; /* don't go to Insert mode */
10126 p_im = FALSE; /* don't use 'insertmode' */
10127
10128 /*
10129 * Save the current typeahead. This is required to allow using ":normal"
10130 * from an event handler and makes sure we don't hang when the argument
10131 * ends with half a command.
10132 */
10133 save_typeahead(&sst->tabuf);
10134 return sst->tabuf.typebuf_valid;
10135 }
10136
10137 void
10138 restore_current_state(save_state_T *sst)
10139 {
10140 /* Restore the previous typeahead. */
10141 restore_typeahead(&sst->tabuf);
10142
10143 msg_scroll = sst->save_msg_scroll;
10144 restart_edit = sst->save_restart_edit;
10145 p_im = sst->save_insertmode;
10146 finish_op = sst->save_finish_op;
10147 opcount = sst->save_opcount;
10148 msg_didout |= sst->save_msg_didout; /* don't reset msg_didout now */
10149
10150 /* Restore the state (needed when called from a function executed for
10151 * 'indentexpr'). Update the mouse and cursor, they may have changed. */
10152 State = sst->save_State;
10153 #ifdef CURSOR_SHAPE
10154 ui_cursor_shape(); /* may show different cursor shape */
10155 #endif
10156 }
10157
10158 /*
10110 * ":normal[!] {commands}": Execute normal mode commands. 10159 * ":normal[!] {commands}": Execute normal mode commands.
10111 */ 10160 */
10112 void 10161 void
10113 ex_normal(exarg_T *eap) 10162 ex_normal(exarg_T *eap)
10114 { 10163 {
10115 int save_msg_scroll = msg_scroll; 10164 save_state_T save_state;
10116 int save_restart_edit = restart_edit;
10117 int save_msg_didout = msg_didout;
10118 int save_State = State;
10119 tasave_T tabuf;
10120 int save_insertmode = p_im;
10121 int save_finish_op = finish_op;
10122 int save_opcount = opcount;
10123 #ifdef FEAT_MBYTE 10165 #ifdef FEAT_MBYTE
10124 char_u *arg = NULL; 10166 char_u *arg = NULL;
10125 int l; 10167 int l;
10126 char_u *p; 10168 char_u *p;
10127 #endif 10169 #endif
10134 if (ex_normal_busy >= p_mmd) 10176 if (ex_normal_busy >= p_mmd)
10135 { 10177 {
10136 EMSG(_("E192: Recursive use of :normal too deep")); 10178 EMSG(_("E192: Recursive use of :normal too deep"));
10137 return; 10179 return;
10138 } 10180 }
10139 ++ex_normal_busy;
10140
10141 msg_scroll = FALSE; /* no msg scrolling in Normal mode */
10142 restart_edit = 0; /* don't go to Insert mode */
10143 p_im = FALSE; /* don't use 'insertmode' */
10144 10181
10145 #ifdef FEAT_MBYTE 10182 #ifdef FEAT_MBYTE
10146 /* 10183 /*
10147 * vgetc() expects a CSI and K_SPECIAL to have been escaped. Don't do 10184 * vgetc() expects a CSI and K_SPECIAL to have been escaped. Don't do
10148 * this for the K_SPECIAL leading byte, otherwise special keys will not 10185 * this for the K_SPECIAL leading byte, otherwise special keys will not
10204 } 10241 }
10205 } 10242 }
10206 } 10243 }
10207 #endif 10244 #endif
10208 10245
10209 /* 10246 ++ex_normal_busy;
10210 * Save the current typeahead. This is required to allow using ":normal" 10247 if (save_current_state(&save_state))
10211 * from an event handler and makes sure we don't hang when the argument
10212 * ends with half a command.
10213 */
10214 save_typeahead(&tabuf);
10215 if (tabuf.typebuf_valid)
10216 { 10248 {
10217 /* 10249 /*
10218 * Repeat the :normal command for each line in the range. When no 10250 * Repeat the :normal command for each line in the range. When no
10219 * range given, execute it just once, without positioning the cursor 10251 * range given, execute it just once, without positioning the cursor
10220 * first. 10252 * first.
10238 } 10270 }
10239 10271
10240 /* Might not return to the main loop when in an event handler. */ 10272 /* Might not return to the main loop when in an event handler. */
10241 update_topline_cursor(); 10273 update_topline_cursor();
10242 10274
10243 /* Restore the previous typeahead. */ 10275 restore_current_state(&save_state);
10244 restore_typeahead(&tabuf);
10245
10246 --ex_normal_busy; 10276 --ex_normal_busy;
10247 msg_scroll = save_msg_scroll;
10248 restart_edit = save_restart_edit;
10249 p_im = save_insertmode;
10250 finish_op = save_finish_op;
10251 opcount = save_opcount;
10252 msg_didout |= save_msg_didout; /* don't reset msg_didout now */
10253
10254 /* Restore the state (needed when called from a function executed for
10255 * 'indentexpr'). Update the mouse and cursor, they may have changed. */
10256 State = save_State;
10257 #ifdef FEAT_MOUSE 10277 #ifdef FEAT_MOUSE
10258 setmouse(); 10278 setmouse();
10259 #endif 10279 #endif
10260 #ifdef CURSOR_SHAPE 10280 #ifdef CURSOR_SHAPE
10261 ui_cursor_shape(); /* may show different cursor shape */ 10281 ui_cursor_shape(); /* may show different cursor shape */