]> granicus.if.org Git - vim/commitdiff
patch 8.1.2212: cannot see the selection type in :reg output v8.1.2212
authorBram Moolenaar <Bram@vim.org>
Thu, 24 Oct 2019 18:17:00 +0000 (20:17 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 24 Oct 2019 18:17:00 +0000 (20:17 +0200)
Problem:    Cannot see the selection type in :reg output. (Ayberk Aydın)
Solution:   Add c/l/b. (Christian Brabandt, closes #5110, closes #4546)

runtime/doc/change.txt
src/register.c
src/testdir/test_registers.vim
src/version.c

index 9b8155ca91917afb8f0f3e99ac836b53bc7fdf32..eda0d6cfbf2837dba57dd6d0effd91ff3851776e 100644 (file)
@@ -999,9 +999,13 @@ inside of strings can change!  Also see 'softtabstop' option. >
                        delete and yank) ({.%#:} only work with put).
 
                                                        *:reg* *:registers*
-:reg[isters]           Display the contents of all numbered and named
-                       registers.  If a register is written to for |:redir|
-                       it will not be listed.
+:reg[isters]           Display the type and contents of all numbered and
+                       named registers.  If a register is written to for
+                       |:redir| it will not be listed.
+                       Type can be one of:
+                       "c"     for |characterwise| text
+                       "l"     for |linewise| text
+                       "b"     for |blockwise-visual| text
 
 
 :reg[isters] {arg}     Display the contents of the numbered and named
index a7e13775b28c474692bf2965c2045b98abcf8917..ccf9b6447bbc0d4be7d323578c6763086cbf48c7 100644 (file)
@@ -2161,16 +2161,23 @@ ex_display(exarg_T *eap)
     int                attr;
     char_u     *arg = eap->arg;
     int                clen;
+    char_u      type[2];
 
     if (arg != NULL && *arg == NUL)
        arg = NULL;
     attr = HL_ATTR(HLF_8);
 
     // Highlight title
-    msg_puts_title(_("\n--- Registers ---"));
+    msg_puts_title(_("\nType Name Content"));
     for (i = -1; i < NUM_REGISTERS && !got_int; ++i)
     {
        name = get_register_name(i);
+       switch (get_reg_type(name, NULL))
+       {
+           case MLINE: type[0] = 'l'; break;
+           case MCHAR: type[0] = 'c'; break;
+           default:    type[0] = 'b'; break;
+       }
        if (arg != NULL && vim_strchr(arg, name) == NULL
 #ifdef ONE_CLIPBOARD
            // Star register and plus register contain the same thing.
@@ -2207,11 +2214,14 @@ ex_display(exarg_T *eap)
        if (yb->y_array != NULL)
        {
            msg_putchar('\n');
+           msg_puts("  ");
+           msg_putchar(type[0]);
+           msg_puts("  ");
            msg_putchar('"');
            msg_putchar(name);
            msg_puts("   ");
 
-           n = (int)Columns - 6;
+           n = (int)Columns - 11;
            for (j = 0; j < yb->y_size && n > 1; ++j)
            {
                if (j)
@@ -2237,7 +2247,7 @@ ex_display(exarg_T *eap)
     if ((p = get_last_insert()) != NULL
                 && (arg == NULL || vim_strchr(arg, '.') != NULL) && !got_int)
     {
-       msg_puts("\n\".   ");
+       msg_puts("\n  c  \".   ");
        dis_msg(p, TRUE);
     }
 
@@ -2245,7 +2255,7 @@ ex_display(exarg_T *eap)
     if (last_cmdline != NULL && (arg == NULL || vim_strchr(arg, ':') != NULL)
                                                                  && !got_int)
     {
-       msg_puts("\n\":   ");
+       msg_puts("\n  c  \":   ");
        dis_msg(last_cmdline, FALSE);
     }
 
@@ -2253,7 +2263,7 @@ ex_display(exarg_T *eap)
     if (curbuf->b_fname != NULL
            && (arg == NULL || vim_strchr(arg, '%') != NULL) && !got_int)
     {
-       msg_puts("\n\"%   ");
+       msg_puts("\n  c  \"%   ");
        dis_msg(curbuf->b_fname, FALSE);
     }
 
@@ -2265,7 +2275,7 @@ ex_display(exarg_T *eap)
 
        if (buflist_name_nr(0, &fname, &dummy) != FAIL)
        {
-           msg_puts("\n\"#   ");
+           msg_puts("\n  c  \"#   ");
            dis_msg(fname, FALSE);
        }
     }
@@ -2274,7 +2284,7 @@ ex_display(exarg_T *eap)
     if (last_search_pat() != NULL
                 && (arg == NULL || vim_strchr(arg, '/') != NULL) && !got_int)
     {
-       msg_puts("\n\"/   ");
+       msg_puts("\n  c  \"/   ");
        dis_msg(last_search_pat(), FALSE);
     }
 
@@ -2283,7 +2293,7 @@ ex_display(exarg_T *eap)
     if (expr_line != NULL && (arg == NULL || vim_strchr(arg, '=') != NULL)
                                                                  && !got_int)
     {
-       msg_puts("\n\"=   ");
+       msg_puts("\n  c  \"=   ");
        dis_msg(expr_line, FALSE);
     }
 #endif
@@ -2515,7 +2525,6 @@ dnd_yank_drag_data(char_u *str, long len)
 #endif
 
 
-#if defined(FEAT_EVAL) || defined(PROTO)
 /*
  * Return the type of a register.
  * Used for getregtype()
@@ -2560,6 +2569,7 @@ get_reg_type(int regname, long *reglen)
     return MAUTO;
 }
 
+#if defined(FEAT_EVAL) || defined(PROTO)
 /*
  * When "flags" has GREG_LIST return a list with text "s".
  * Otherwise just return "s".
index 3f4942e2ef5d7f7e723d3fa2e62122c0d61a8863..d9cf7ed403a4d9d67c376b9bc0816a5a96745b62 100644 (file)
@@ -39,26 +39,26 @@ func Test_display_registers()
     let b = execute('registers')
 
     call assert_equal(a, b)
-    call assert_match('^\n--- Registers ---\n'
-          \ .         '""   a\n'
-          \ .         '"0   ba\n'
-          \ .         '"a   b\n'
+    call assert_match('^\nType Name Content\n'
+          \ .         '  c  ""   a\n'
+          \ .         '  c  "0   ba\n'
+          \ .         '  c  "a   b\n'
           \ .         '.*'
-          \ .         '"-   a\n'
+          \ .         '  c  "-   a\n'
           \ .         '.*'
-          \ .         '":   ls\n'
-          \ .         '"%   file2\n'
-          \ .         '"#   file1\n'
-          \ .         '"/   bar\n'
-          \ .         '"=   2\*4', a)
+          \ .         '  c  ":   ls\n'
+          \ .         '  c  "%   file2\n'
+          \ .         '  c  "#   file1\n'
+          \ .         '  c  "/   bar\n'
+          \ .         '  c  "=   2\*4', a)
 
     let a = execute('registers a')
-    call assert_match('^\n--- Registers ---\n'
-          \ .         '"a   b', a)
+    call assert_match('^\nType Name Content\n'
+          \ .         '  c  "a   b', a)
 
     let a = execute('registers :')
-    call assert_match('^\n--- Registers ---\n'
-          \ .         '":   ls', a)
+    call assert_match('^\nType Name Content\n'
+          \ .         '  c  ":   ls', a)
 
     bwipe!
 endfunc
index 45c7bc07a11a3aae92f6aa42bfe9f76832daf629..c5e925e42a16e5d23ca6988d2360386e7cc7a738 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2212,
 /**/
     2211,
 /**/