comparison src/menu.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 3f16cf18386c
children 259983a729fa
comparison
equal deleted inserted replaced
12520:983f47a69df0 12521:718787498836
2240 */ 2240 */
2241 static void 2241 static void
2242 execute_menu(exarg_T *eap, vimmenu_T *menu) 2242 execute_menu(exarg_T *eap, vimmenu_T *menu)
2243 { 2243 {
2244 char_u *mode; 2244 char_u *mode;
2245 int idx; 2245 int idx = -1;
2246 2246
2247 /* Use the Insert mode entry when returning to Insert mode. */ 2247 /* Use the Insert mode entry when returning to Insert mode. */
2248 if (restart_edit 2248 if (restart_edit
2249 #ifdef FEAT_EVAL 2249 #ifdef FEAT_EVAL
2250 && !current_SID 2250 && !current_SID
2304 /* Adjust the cursor to make sure it is in the correct pos 2304 /* Adjust the cursor to make sure it is in the correct pos
2305 * for exclusive mode */ 2305 * for exclusive mode */
2306 if (*p_sel == 'e' && gchar_cursor() != NUL) 2306 if (*p_sel == 'e' && gchar_cursor() != NUL)
2307 ++curwin->w_cursor.col; 2307 ++curwin->w_cursor.col;
2308 } 2308 }
2309 else 2309
2310 /* For the WinBar menu always use the Normal mode menu. */
2311 if (idx == -1 || eap == NULL)
2310 { 2312 {
2311 mode = (char_u *)"Normal"; 2313 mode = (char_u *)"Normal";
2312 idx = MENU_INDEX_NORMAL; 2314 idx = MENU_INDEX_NORMAL;
2313 } 2315 }
2314 2316
2320 if (eap == NULL 2322 if (eap == NULL
2321 #ifdef FEAT_EVAL 2323 #ifdef FEAT_EVAL
2322 || current_SID != 0 2324 || current_SID != 0
2323 #endif 2325 #endif
2324 ) 2326 )
2325 exec_normal_cmd(menu->strings[idx], menu->noremap[idx], 2327 {
2328 save_state_T save_state;
2329
2330 ++ex_normal_busy;
2331 if (save_current_state(&save_state))
2332 exec_normal_cmd(menu->strings[idx], menu->noremap[idx],
2326 menu->silent[idx]); 2333 menu->silent[idx]);
2334 restore_current_state(&save_state);
2335 --ex_normal_busy;
2336 }
2327 else 2337 else
2328 ins_typebuf(menu->strings[idx], menu->noremap[idx], 0, 2338 ins_typebuf(menu->strings[idx], menu->noremap[idx], 0,
2329 TRUE, menu->silent[idx]); 2339 TRUE, menu->silent[idx]);
2330 } 2340 }
2331 else if (eap != NULL) 2341 else if (eap != NULL)
2404 winbar_item_T *item = &wp->w_winbar_items[idx]; 2414 winbar_item_T *item = &wp->w_winbar_items[idx];
2405 2415
2406 if (col >= item->wb_startcol && col <= item->wb_endcol) 2416 if (col >= item->wb_startcol && col <= item->wb_endcol)
2407 { 2417 {
2408 win_T *save_curwin = NULL; 2418 win_T *save_curwin = NULL;
2419 pos_T save_visual = VIsual;
2420 int save_visual_active = VIsual_active;
2421 int save_visual_select = VIsual_select;
2422 int save_visual_reselect = VIsual_reselect;
2423 int save_visual_mode = VIsual_mode;
2409 2424
2410 if (wp != curwin) 2425 if (wp != curwin)
2411 { 2426 {
2412 /* Clicking in the window toolbar of a not-current window. 2427 /* Clicking in the window toolbar of a not-current window.
2413 * Make that window the current one and go to Normal mode. */ 2428 * Make that window the current one and save Visual mode. */
2414 save_curwin = curwin; 2429 save_curwin = curwin;
2430 VIsual_active = FALSE;
2415 curwin = wp; 2431 curwin = wp;
2416 curbuf = curwin->w_buffer; 2432 curbuf = curwin->w_buffer;
2417 check_cursor(); 2433 check_cursor();
2418 } 2434 }
2419 2435
2421 2437
2422 if (save_curwin != NULL) 2438 if (save_curwin != NULL)
2423 { 2439 {
2424 curwin = save_curwin; 2440 curwin = save_curwin;
2425 curbuf = curwin->w_buffer; 2441 curbuf = curwin->w_buffer;
2442 VIsual = save_visual;
2443 VIsual_active = save_visual_active;
2444 VIsual_select = save_visual_select;
2445 VIsual_reselect = save_visual_reselect;
2446 VIsual_mode = save_visual_mode;
2426 } 2447 }
2427 } 2448 }
2428 } 2449 }
2429 } 2450 }
2430 2451