comparison src/misc1.c @ 26042:6b39ab99e367 v8.2.3555

patch 8.2.3555: ModeChanged is not triggered on every mode change Commit: https://github.com/vim/vim/commit/25def2c8b8bd7b0c3d5f020207c717a880b05d50 Author: =?UTF-8?q?Magnus=20Gro=C3=9F?= <magnus.gross@rwth-aachen.de> Date: Fri Oct 22 18:56:39 2021 +0100 patch 8.2.3555: ModeChanged is not triggered on every mode change Problem: ModeChanged is not triggered on every mode change. Solution: Also trigger on minor mode changes. (Maguns Gross, closes https://github.com/vim/vim/issues/8999)
author Bram Moolenaar <Bram@vim.org>
date Fri, 22 Oct 2021 20:00:05 +0200
parents 9b2c6cea573c
children f2392648af3e
comparison
equal deleted inserted replaced
26041:1f1f9e2a021b 26042:6b39ab99e367
2668 char_u *pat; 2668 char_u *pat;
2669 2669
2670 if (!has_modechanged()) 2670 if (!has_modechanged())
2671 return; 2671 return;
2672 2672
2673 v_event = get_vim_var_dict(VV_EVENT);
2674
2675 tv[0].v_type = VAR_NUMBER; 2673 tv[0].v_type = VAR_NUMBER;
2676 tv[0].vval.v_number = 1; // get full mode 2674 tv[0].vval.v_number = 1; // get full mode
2677 tv[1].v_type = VAR_UNKNOWN; 2675 tv[1].v_type = VAR_UNKNOWN;
2678 f_mode(tv, &rettv); 2676 f_mode(tv, &rettv);
2677 if (STRCMP(rettv.vval.v_string, last_mode) == 0)
2678 {
2679 vim_free(rettv.vval.v_string);
2680 return;
2681 }
2682
2683 v_event = get_vim_var_dict(VV_EVENT);
2679 (void)dict_add_string(v_event, "new_mode", rettv.vval.v_string); 2684 (void)dict_add_string(v_event, "new_mode", rettv.vval.v_string);
2680 (void)dict_add_string(v_event, "old_mode", last_mode); 2685 (void)dict_add_string(v_event, "old_mode", last_mode);
2681 dict_set_items_ro(v_event); 2686 dict_set_items_ro(v_event);
2682 2687
2683 // concatenate modes in format "old_mode:new_mode" 2688 // concatenate modes in format "old_mode:new_mode"
2686 vim_free(pat_pre); 2691 vim_free(pat_pre);
2687 2692
2688 apply_autocmds(EVENT_MODECHANGED, pat, NULL, FALSE, curbuf); 2693 apply_autocmds(EVENT_MODECHANGED, pat, NULL, FALSE, curbuf);
2689 STRCPY(last_mode, rettv.vval.v_string); 2694 STRCPY(last_mode, rettv.vval.v_string);
2690 2695
2691 vim_free(rettv.vval.v_string);
2692 vim_free(pat); 2696 vim_free(pat);
2693 dict_free_contents(v_event); 2697 dict_free_contents(v_event);
2694 hash_init(&v_event->dv_hashtab); 2698 hash_init(&v_event->dv_hashtab);
2695 #endif 2699 vim_free(rettv.vval.v_string);
2696 } 2700 #endif
2701 }