Skip to content

Commit 3691f1e

Browse files
committed
patch 8.1.2212: cannot see the selection type in :reg output
Problem: Cannot see the selection type in :reg output. (Ayberk Aydın) Solution: Add c/l/b. (Christian Brabandt, closes #5110, closes #4546)
1 parent 336bf2b commit 3691f1e

4 files changed

Lines changed: 42 additions & 26 deletions

File tree

runtime/doc/change.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -999,9 +999,13 @@ inside of strings can change! Also see 'softtabstop' option. >
999999
delete and yank) ({.%#:} only work with put).
10001000

10011001
*:reg* *:registers*
1002-
:reg[isters] Display the contents of all numbered and named
1003-
registers. If a register is written to for |:redir|
1004-
it will not be listed.
1002+
:reg[isters] Display the type and contents of all numbered and
1003+
named registers. If a register is written to for
1004+
|:redir| it will not be listed.
1005+
Type can be one of:
1006+
"c" for |characterwise| text
1007+
"l" for |linewise| text
1008+
"b" for |blockwise-visual| text
10051009

10061010

10071011
:reg[isters] {arg} Display the contents of the numbered and named

src/register.c

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2161,16 +2161,23 @@ ex_display(exarg_T *eap)
21612161
int attr;
21622162
char_u *arg = eap->arg;
21632163
int clen;
2164+
char_u type[2];
21642165

21652166
if (arg != NULL && *arg == NUL)
21662167
arg = NULL;
21672168
attr = HL_ATTR(HLF_8);
21682169

21692170
// Highlight title
2170-
msg_puts_title(_("\n--- Registers ---"));
2171+
msg_puts_title(_("\nType Name Content"));
21712172
for (i = -1; i < NUM_REGISTERS && !got_int; ++i)
21722173
{
21732174
name = get_register_name(i);
2175+
switch (get_reg_type(name, NULL))
2176+
{
2177+
case MLINE: type[0] = 'l'; break;
2178+
case MCHAR: type[0] = 'c'; break;
2179+
default: type[0] = 'b'; break;
2180+
}
21742181
if (arg != NULL && vim_strchr(arg, name) == NULL
21752182
#ifdef ONE_CLIPBOARD
21762183
// Star register and plus register contain the same thing.
@@ -2207,11 +2214,14 @@ ex_display(exarg_T *eap)
22072214
if (yb->y_array != NULL)
22082215
{
22092216
msg_putchar('\n');
2217+
msg_puts(" ");
2218+
msg_putchar(type[0]);
2219+
msg_puts(" ");
22102220
msg_putchar('"');
22112221
msg_putchar(name);
22122222
msg_puts(" ");
22132223

2214-
n = (int)Columns - 6;
2224+
n = (int)Columns - 11;
22152225
for (j = 0; j < yb->y_size && n > 1; ++j)
22162226
{
22172227
if (j)
@@ -2237,23 +2247,23 @@ ex_display(exarg_T *eap)
22372247
if ((p = get_last_insert()) != NULL
22382248
&& (arg == NULL || vim_strchr(arg, '.') != NULL) && !got_int)
22392249
{
2240-
msg_puts("\n\". ");
2250+
msg_puts("\n c \". ");
22412251
dis_msg(p, TRUE);
22422252
}
22432253

22442254
// display last command line
22452255
if (last_cmdline != NULL && (arg == NULL || vim_strchr(arg, ':') != NULL)
22462256
&& !got_int)
22472257
{
2248-
msg_puts("\n\": ");
2258+
msg_puts("\n c \": ");
22492259
dis_msg(last_cmdline, FALSE);
22502260
}
22512261

22522262
// display current file name
22532263
if (curbuf->b_fname != NULL
22542264
&& (arg == NULL || vim_strchr(arg, '%') != NULL) && !got_int)
22552265
{
2256-
msg_puts("\n\"% ");
2266+
msg_puts("\n c \"% ");
22572267
dis_msg(curbuf->b_fname, FALSE);
22582268
}
22592269

@@ -2265,7 +2275,7 @@ ex_display(exarg_T *eap)
22652275

22662276
if (buflist_name_nr(0, &fname, &dummy) != FAIL)
22672277
{
2268-
msg_puts("\n\"# ");
2278+
msg_puts("\n c \"# ");
22692279
dis_msg(fname, FALSE);
22702280
}
22712281
}
@@ -2274,7 +2284,7 @@ ex_display(exarg_T *eap)
22742284
if (last_search_pat() != NULL
22752285
&& (arg == NULL || vim_strchr(arg, '/') != NULL) && !got_int)
22762286
{
2277-
msg_puts("\n\"/ ");
2287+
msg_puts("\n c \"/ ");
22782288
dis_msg(last_search_pat(), FALSE);
22792289
}
22802290

@@ -2283,7 +2293,7 @@ ex_display(exarg_T *eap)
22832293
if (expr_line != NULL && (arg == NULL || vim_strchr(arg, '=') != NULL)
22842294
&& !got_int)
22852295
{
2286-
msg_puts("\n\"= ");
2296+
msg_puts("\n c \"= ");
22872297
dis_msg(expr_line, FALSE);
22882298
}
22892299
#endif
@@ -2515,7 +2525,6 @@ dnd_yank_drag_data(char_u *str, long len)
25152525
#endif
25162526

25172527

2518-
#if defined(FEAT_EVAL) || defined(PROTO)
25192528
/*
25202529
* Return the type of a register.
25212530
* Used for getregtype()
@@ -2560,6 +2569,7 @@ get_reg_type(int regname, long *reglen)
25602569
return MAUTO;
25612570
}
25622571

2572+
#if defined(FEAT_EVAL) || defined(PROTO)
25632573
/*
25642574
* When "flags" has GREG_LIST return a list with text "s".
25652575
* Otherwise just return "s".

src/testdir/test_registers.vim

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,26 @@ func Test_display_registers()
3939
let b = execute('registers')
4040

4141
call assert_equal(a, b)
42-
call assert_match('^\n--- Registers ---\n'
43-
\ . '"" a\n'
44-
\ . '"0 ba\n'
45-
\ . '"a b\n'
42+
call assert_match('^\nType Name Content\n'
43+
\ . ' c "" a\n'
44+
\ . ' c "0 ba\n'
45+
\ . ' c "a b\n'
4646
\ . '.*'
47-
\ . '"- a\n'
47+
\ . ' c "- a\n'
4848
\ . '.*'
49-
\ . '": ls\n'
50-
\ . '"% file2\n'
51-
\ . '"# file1\n'
52-
\ . '"/ bar\n'
53-
\ . '"= 2\*4', a)
49+
\ . ' c ": ls\n'
50+
\ . ' c "% file2\n'
51+
\ . ' c "# file1\n'
52+
\ . ' c "/ bar\n'
53+
\ . ' c "= 2\*4', a)
5454

5555
let a = execute('registers a')
56-
call assert_match('^\n--- Registers ---\n'
57-
\ . '"a b', a)
56+
call assert_match('^\nType Name Content\n'
57+
\ . ' c "a b', a)
5858

5959
let a = execute('registers :')
60-
call assert_match('^\n--- Registers ---\n'
61-
\ . '": ls', a)
60+
call assert_match('^\nType Name Content\n'
61+
\ . ' c ": ls', a)
6262

6363
bwipe!
6464
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ static char *(features[]) =
741741

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
2212,
744746
/**/
745747
2211,
746748
/**/

0 commit comments

Comments
 (0)