diff src/normal.c @ 31457:bb797331e21b v9.0.1061

patch 9.0.1061: cannot display 'showcmd' somewhere else Commit: https://github.com/vim/vim/commit/ba936f6f4e85cc1408bc3967f9fd7665d948909b Author: Luuk van Baal <luukvbaal@gmail.com> Date: Thu Dec 15 13:15:39 2022 +0000 patch 9.0.1061: cannot display 'showcmd' somewhere else Problem: Cannot display 'showcmd' somewhere else. Solution: Add the 'showcmdloc' option. (Luuk van Baal, closes https://github.com/vim/vim/issues/11684)
author Bram Moolenaar <Bram@vim.org>
date Thu, 15 Dec 2022 14:30:05 +0100
parents ff4473b3fc58
children e94571ac4134
line wrap: on
line diff
--- a/src/normal.c
+++ b/src/normal.c
@@ -1574,8 +1574,6 @@ may_clear_cmdline(void)
  * Routines for displaying a partly typed command
  */
 
-#define SHOWCMD_BUFLEN (SHOWCMD_COLS + 1 + 30)
-static char_u	showcmd_buf[SHOWCMD_BUFLEN];
 static char_u	old_showcmd_buf[SHOWCMD_BUFLEN];  // For push_showcmd()
 static int	showcmd_is_clear = TRUE;
 static int	showcmd_visual = FALSE;
@@ -1798,22 +1796,25 @@ pop_showcmd(void)
     static void
 display_showcmd(void)
 {
-    int	    len;
-
+    int	    len = (int)STRLEN(showcmd_buf);
+
+    showcmd_is_clear = (len == 0);
     cursor_off();
 
-    len = (int)STRLEN(showcmd_buf);
-    if (len == 0)
-	showcmd_is_clear = TRUE;
-    else
-    {
-	screen_puts(showcmd_buf, (int)Rows - 1, sc_col, 0);
-	showcmd_is_clear = FALSE;
-    }
-
-    // clear the rest of an old message by outputting up to SHOWCMD_COLS
-    // spaces
-    screen_puts((char_u *)"          " + len, (int)Rows - 1, sc_col + len, 0);
+    if (*p_sloc == 's')
+	win_redr_status(curwin, FALSE);
+    else if (*p_sloc == 't')
+	draw_tabline();
+    else // 'showcmdloc' is "last" or empty
+    {
+	if (!showcmd_is_clear)
+	    screen_puts(showcmd_buf, (int)Rows - 1, sc_col, 0);
+
+	// clear the rest of an old message by outputting up to SHOWCMD_COLS
+	// spaces
+	screen_puts((char_u *)"          " + len,
+						(int)Rows - 1, sc_col + len, 0);
+    }
 
     setcursor();	    // put cursor back where it belongs
 }