mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	refactor(ui): remove some superfluous ui_flush() calls
- <expr> mapping has no business saving and restoring the low-level UI cursor. The cursor will be put in a reasonable position after input is processed, chill out. - TUI handles output needed for suspend - vgetc() family of function does flushing
This commit is contained in:
		| @@ -7469,7 +7469,6 @@ void ex_execute(exarg_T *eap) | |||||||
|     if (eap->cmdidx == CMD_echomsg) { |     if (eap->cmdidx == CMD_echomsg) { | ||||||
|       msg_ext_set_kind("echomsg"); |       msg_ext_set_kind("echomsg"); | ||||||
|       msg_attr(ga.ga_data, echo_attr); |       msg_attr(ga.ga_data, echo_attr); | ||||||
|       ui_flush(); |  | ||||||
|     } else if (eap->cmdidx == CMD_echoerr) { |     } else if (eap->cmdidx == CMD_echoerr) { | ||||||
|       // We don't want to abort following commands, restore did_emsg. |       // We don't want to abort following commands, restore did_emsg. | ||||||
|       int save_did_emsg = did_emsg; |       int save_did_emsg = did_emsg; | ||||||
|   | |||||||
| @@ -2150,8 +2150,7 @@ void ex_function(exarg_T *eap) | |||||||
|             } |             } | ||||||
|           } |           } | ||||||
|           msg_prt_line(FUNCLINE(fp, j), false); |           msg_prt_line(FUNCLINE(fp, j), false); | ||||||
|           ui_flush();                  // show a line at a time |           line_breakcheck();  // show multiple lines at a time! | ||||||
|           os_breakcheck(); |  | ||||||
|         } |         } | ||||||
|         if (!got_int) { |         if (!got_int) { | ||||||
|           msg_putchar('\n'); |           msg_putchar('\n'); | ||||||
|   | |||||||
| @@ -1507,7 +1507,6 @@ void print_line(linenr_T lnum, int use_number, int list) | |||||||
|   print_line_no_prefix(lnum, use_number, list); |   print_line_no_prefix(lnum, use_number, list); | ||||||
|   if (save_silent) { |   if (save_silent) { | ||||||
|     msg_putchar('\n'); |     msg_putchar('\n'); | ||||||
|     ui_flush(); |  | ||||||
|     silent_mode = save_silent; |     silent_mode = save_silent; | ||||||
|   } |   } | ||||||
|   info_message = false; |   info_message = false; | ||||||
|   | |||||||
| @@ -4838,13 +4838,9 @@ static void ex_stop(exarg_T *eap) | |||||||
|   } |   } | ||||||
|   apply_autocmds(EVENT_VIMSUSPEND, NULL, NULL, false, NULL); |   apply_autocmds(EVENT_VIMSUSPEND, NULL, NULL, false, NULL); | ||||||
|  |  | ||||||
|   // TODO(bfredl): the TUI should do this on suspend |   ui_call_suspend(); | ||||||
|   ui_cursor_goto(Rows - 1, 0); |  | ||||||
|   ui_call_grid_scroll(1, 0, Rows, 0, Columns, 1, 0); |  | ||||||
|   ui_flush(); |   ui_flush(); | ||||||
|   ui_call_suspend();  // call machine specific function |  | ||||||
|  |  | ||||||
|   ui_flush(); |  | ||||||
|   maketitle(); |   maketitle(); | ||||||
|   resettitle();  // force updating the title |   resettitle();  // force updating the title | ||||||
|   ui_refresh();  // may have resized window |   ui_refresh();  // may have resized window | ||||||
|   | |||||||
| @@ -2218,9 +2218,6 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth) | |||||||
|     if (mp->m_expr) { |     if (mp->m_expr) { | ||||||
|       const int save_vgetc_busy = vgetc_busy; |       const int save_vgetc_busy = vgetc_busy; | ||||||
|       const bool save_may_garbage_collect = may_garbage_collect; |       const bool save_may_garbage_collect = may_garbage_collect; | ||||||
|       const int save_cursor_row = ui_current_row(); |  | ||||||
|       const int save_cursor_col = ui_current_col(); |  | ||||||
|       const handle_T save_cursor_grid = ui_cursor_grid(); |  | ||||||
|       const int prev_did_emsg = did_emsg; |       const int prev_did_emsg = did_emsg; | ||||||
|  |  | ||||||
|       vgetc_busy = 0; |       vgetc_busy = 0; | ||||||
| @@ -2232,28 +2229,28 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth) | |||||||
|       } |       } | ||||||
|       map_str = eval_map_expr(mp, NUL); |       map_str = eval_map_expr(mp, NUL); | ||||||
|  |  | ||||||
|       // The mapping may do anything, but we expect it to take care of |       if ((map_str == NULL || *map_str == NUL)) { | ||||||
|       // redrawing.  Do put the cursor back where it was. |         // If an error was displayed and the expression returns an empty | ||||||
|       ui_grid_cursor_goto(save_cursor_grid, save_cursor_row, save_cursor_col); |         // string, generate a <Nop> to allow for a redraw. | ||||||
|       ui_flush(); |         if (prev_did_emsg != did_emsg) { | ||||||
|  |           char buf[4]; | ||||||
|       // If an error was displayed and the expression returns an empty |           xfree(map_str); | ||||||
|       // string, generate a <Nop> to allow for a redraw. |           buf[0] = (char)K_SPECIAL; | ||||||
|       if (prev_did_emsg != did_emsg && (map_str == NULL || *map_str == NUL)) { |           buf[1] = (char)KS_EXTRA; | ||||||
|         char buf[4]; |           buf[2] = KE_IGNORE; | ||||||
|         xfree(map_str); |           buf[3] = NUL; | ||||||
|         buf[0] = (char)K_SPECIAL; |           map_str = xstrdup(buf); | ||||||
|         buf[1] = (char)KS_EXTRA; |           if (State & MODE_CMDLINE) { | ||||||
|         buf[2] = KE_IGNORE; |             // redraw the command below the error | ||||||
|         buf[3] = NUL; |             msg_didout = true; | ||||||
|         map_str = xstrdup(buf); |             if (msg_row < cmdline_row) { | ||||||
|         if (State & MODE_CMDLINE) { |               msg_row = cmdline_row; | ||||||
|           // redraw the command below the error |             } | ||||||
|           msg_didout = true; |             redrawcmd(); | ||||||
|           if (msg_row < cmdline_row) { |  | ||||||
|             msg_row = cmdline_row; |  | ||||||
|           } |           } | ||||||
|           redrawcmd(); |         } else if (State & (MODE_NORMAL | MODE_INSERT)) { | ||||||
|  |           // otherwise, just put back the cursor | ||||||
|  |           setcursor(); | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1549,7 +1549,6 @@ int do_set(char *arg, int opt_flags) | |||||||
|     silent_mode = false; |     silent_mode = false; | ||||||
|     info_message = true;        // use os_msg(), not os_errmsg() |     info_message = true;        // use os_msg(), not os_errmsg() | ||||||
|     msg_putchar('\n'); |     msg_putchar('\n'); | ||||||
|     ui_flush(); |  | ||||||
|     silent_mode = true; |     silent_mode = true; | ||||||
|     info_message = false;       // use os_msg(), not os_errmsg() |     info_message = false;       // use os_msg(), not os_errmsg() | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -1092,7 +1092,6 @@ void pum_show_popupmenu(vimmenu_T *menu) | |||||||
|     pum_is_drawn = true; |     pum_is_drawn = true; | ||||||
|     pum_redraw(); |     pum_redraw(); | ||||||
|     setcursor_mayforce(true); |     setcursor_mayforce(true); | ||||||
|     ui_flush(); |  | ||||||
|  |  | ||||||
|     int c = vgetc(); |     int c = vgetc(); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -472,11 +472,6 @@ int ui_current_col(void) | |||||||
|   return cursor_col; |   return cursor_col; | ||||||
| } | } | ||||||
|  |  | ||||||
| handle_T ui_cursor_grid(void) |  | ||||||
| { |  | ||||||
|   return cursor_grid_handle; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| void ui_flush(void) | void ui_flush(void) | ||||||
| { | { | ||||||
|   assert(!ui_client_channel_id); |   assert(!ui_client_channel_id); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 bfredl
					bfredl