comparison src/getchar.c @ 27624:ec52847967d8 v8.2.4338

patch 8.2.4338: an error from an expression mapping messes up the display Commit: https://github.com/vim/vim/commit/74a0a5b26d0180f3ea89e9495dff6a26f0df23cb Author: Bram Moolenaar <Bram@vim.org> Date: Thu Feb 10 14:07:41 2022 +0000 patch 8.2.4338: an error from an expression mapping messes up the display Problem: An error from an expression mapping messes up the display. Solution: When the expression results in an empty string return K_IGNORE. In cmdline mode redraw the command line. (closes #9726)
author Bram Moolenaar <Bram@vim.org>
date Thu, 10 Feb 2022 15:15:04 +0100
parents 4c7bb6fd383f
children 4cc78957f550
comparison
equal deleted inserted replaced
27623:179c118424a6 27624:ec52847967d8
2838 { 2838 {
2839 int save_vgetc_busy = vgetc_busy; 2839 int save_vgetc_busy = vgetc_busy;
2840 int save_may_garbage_collect = may_garbage_collect; 2840 int save_may_garbage_collect = may_garbage_collect;
2841 int was_screen_col = screen_cur_col; 2841 int was_screen_col = screen_cur_col;
2842 int was_screen_row = screen_cur_row; 2842 int was_screen_row = screen_cur_row;
2843 int prev_did_emsg = did_emsg;
2843 2844
2844 vgetc_busy = 0; 2845 vgetc_busy = 0;
2845 may_garbage_collect = FALSE; 2846 may_garbage_collect = FALSE;
2846 2847
2847 save_m_keys = vim_strsave(mp->m_keys); 2848 save_m_keys = vim_strsave(mp->m_keys);
2849 2850
2850 // The mapping may do anything, but we expect it to take care of 2851 // The mapping may do anything, but we expect it to take care of
2851 // redrawing. Do put the cursor back where it was. 2852 // redrawing. Do put the cursor back where it was.
2852 windgoto(was_screen_row, was_screen_col); 2853 windgoto(was_screen_row, was_screen_col);
2853 out_flush(); 2854 out_flush();
2855
2856 // If an error was displayed and the expression returns an empty
2857 // string, generate a <Nop> to allow for a redraw.
2858 if (prev_did_emsg != did_emsg
2859 && (map_str == NULL || *map_str == NUL))
2860 {
2861 char_u buf[4];
2862
2863 vim_free(map_str);
2864 buf[0] = K_SPECIAL;
2865 buf[1] = KS_EXTRA;
2866 buf[2] = KE_IGNORE;
2867 buf[3] = NUL;
2868 map_str = vim_strsave(buf);
2869 if (State & CMDLINE)
2870 {
2871 // redraw the command below the error
2872 msg_didout = TRUE;
2873 if (msg_row < cmdline_row)
2874 msg_row = cmdline_row;
2875 redrawcmd();
2876 }
2877 }
2854 2878
2855 vgetc_busy = save_vgetc_busy; 2879 vgetc_busy = save_vgetc_busy;
2856 may_garbage_collect = save_may_garbage_collect; 2880 may_garbage_collect = save_may_garbage_collect;
2857 } 2881 }
2858 else 2882 else