vim-patch:8.1.0701: sign message not translated and inconsistent spacing

Problem:    Sign message not translated and inconsistent spacing.
Solution:   Add _() for translation.  Add a space. (Ken Takata)  Also use
            MSG_BUF_LEN instead of BUFSIZ.
d730c8e297
This commit is contained in:
Andrej Zieger
2019-05-20 08:57:49 +02:00
parent e70609cfac
commit 35fbb4e1ca
3 changed files with 33 additions and 32 deletions

View File

@@ -594,8 +594,8 @@ void sign_list_placed(buf_T *rbuf, char_u *sign_group)
{ {
buf_T *buf; buf_T *buf;
signlist_T *sign; signlist_T *sign;
char lbuf[BUFSIZ]; char lbuf[MSG_BUF_LEN];
char group[BUFSIZ]; char group[MSG_BUF_LEN];
MSG_PUTS_TITLE(_("\n--- Signs ---")); MSG_PUTS_TITLE(_("\n--- Signs ---"));
msg_putchar('\n'); msg_putchar('\n');
@@ -606,7 +606,7 @@ void sign_list_placed(buf_T *rbuf, char_u *sign_group)
} }
while (buf != NULL && !got_int) { while (buf != NULL && !got_int) {
if (buf->b_signlist != NULL) { if (buf->b_signlist != NULL) {
vim_snprintf(lbuf, BUFSIZ, _("Signs for %s:"), buf->b_fname); vim_snprintf(lbuf, MSG_BUF_LEN, _("Signs for %s:"), buf->b_fname);
MSG_PUTS_ATTR(lbuf, HL_ATTR(HLF_D)); MSG_PUTS_ATTR(lbuf, HL_ATTR(HLF_D));
msg_putchar('\n'); msg_putchar('\n');
} }
@@ -618,14 +618,15 @@ void sign_list_placed(buf_T *rbuf, char_u *sign_group)
continue; continue;
} }
if (sign->group != NULL) { if (sign->group != NULL) {
vim_snprintf(group, BUFSIZ, " group=%s", sign->group->sg_name); vim_snprintf(group, MSG_BUF_LEN, _(" group=%s"),
sign->group->sg_name);
} else { } else {
group[0] = '\0'; group[0] = '\0';
} }
vim_snprintf(lbuf, BUFSIZ, _(" line=%ld id=%d%s name=%s " vim_snprintf(lbuf, MSG_BUF_LEN,
"priority=%d"), _(" line=%ld id=%d%s name=%s priority=%d"),
(long)sign->lnum, sign->id, group, (long)sign->lnum, sign->id, group,
sign_typenr2name(sign->typenr), sign->priority); sign_typenr2name(sign->typenr), sign->priority);
MSG_PUTS(lbuf); MSG_PUTS(lbuf);
msg_putchar('\n'); msg_putchar('\n');
} }

View File

@@ -67,7 +67,7 @@ func Test_sign()
" Check placed signs " Check placed signs
let a=execute('sign place') let a=execute('sign place')
call assert_equal("\n--- Signs ---\nSigns for [NULL]:\n" . call assert_equal("\n--- Signs ---\nSigns for [NULL]:\n" .
\ " line=3 id=41 name=Sign1 priority=10\n", a) \ " line=3 id=41 name=Sign1 priority=10\n", a)
" Unplace the sign and try jumping to it again should fail. " Unplace the sign and try jumping to it again should fail.
sign unplace 41 sign unplace 41
@@ -95,7 +95,7 @@ func Test_sign()
sign place 77 line=9 name=Sign2 sign place 77 line=9 name=Sign2
let a=execute('sign place') let a=execute('sign place')
call assert_equal("\n--- Signs ---\nSigns for [NULL]:\n" . call assert_equal("\n--- Signs ---\nSigns for [NULL]:\n" .
\ " line=9 id=77 name=Sign2 priority=10\n", a) \ " line=9 id=77 name=Sign2 priority=10\n", a)
sign unplace * sign unplace *
" Check :jump with file=... " Check :jump with file=...
@@ -161,7 +161,7 @@ func Test_sign()
exe 'sign place 20 line=3 name=004 buffer=' . bufnr('') exe 'sign place 20 line=3 name=004 buffer=' . bufnr('')
let a = execute('sign place') let a = execute('sign place')
call assert_equal("\n--- Signs ---\nSigns for foo:\n" . call assert_equal("\n--- Signs ---\nSigns for foo:\n" .
\ " line=3 id=20 name=4 priority=10\n", a) \ " line=3 id=20 name=4 priority=10\n", a)
exe 'sign unplace 20 buffer=' . bufnr('') exe 'sign unplace 20 buffer=' . bufnr('')
sign undefine 004 sign undefine 004
call assert_fails('sign list 4', 'E155:') call assert_fails('sign list 4', 'E155:')
@@ -189,7 +189,7 @@ func Test_sign_undefine_still_placed()
" Listing placed sign should show that sign is deleted. " Listing placed sign should show that sign is deleted.
let a=execute('sign place') let a=execute('sign place')
call assert_equal("\n--- Signs ---\nSigns for foobar:\n" . call assert_equal("\n--- Signs ---\nSigns for foobar:\n" .
\ " line=1 id=41 name=[Deleted] priority=10\n", a) \ " line=1 id=41 name=[Deleted] priority=10\n", a)
sign unplace 41 sign unplace 41
let a=execute('sign place') let a=execute('sign place')
@@ -613,19 +613,19 @@ func Test_sign_group()
" :sign place file={fname} " :sign place file={fname}
let a = execute('sign place file=Xsign') let a = execute('sign place file=Xsign')
call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" . call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" .
\ " line=10 id=5 name=sign1 priority=10\n", a) \ " line=10 id=5 name=sign1 priority=10\n", a)
" :sign place group={group} file={fname} " :sign place group={group} file={fname}
let a = execute('sign place group=g2 file=Xsign') let a = execute('sign place group=g2 file=Xsign')
call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" . call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" .
\ " line=10 id=5 group=g2 name=sign1 priority=10\n", a) \ " line=10 id=5 group=g2 name=sign1 priority=10\n", a)
" :sign place group=* file={fname} " :sign place group=* file={fname}
let a = execute('sign place group=* file=Xsign') let a = execute('sign place group=* file=Xsign')
call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" . call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" .
\ " line=10 id=5 group=g2 name=sign1 priority=10\n" . \ " line=10 id=5 group=g2 name=sign1 priority=10\n" .
\ " line=10 id=5 group=g1 name=sign1 priority=10\n" . \ " line=10 id=5 group=g1 name=sign1 priority=10\n" .
\ " line=10 id=5 name=sign1 priority=10\n", a) \ " line=10 id=5 name=sign1 priority=10\n", a)
" Error case: non-existing group " Error case: non-existing group
let a = execute('sign place group=xyz file=Xsign') let a = execute('sign place group=xyz file=Xsign')
@@ -640,19 +640,19 @@ func Test_sign_group()
" :sign place buffer={fname} " :sign place buffer={fname}
let a = execute('sign place buffer=' . bnum) let a = execute('sign place buffer=' . bnum)
call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" . call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" .
\ " line=10 id=5 name=sign1 priority=10\n", a) \ " line=10 id=5 name=sign1 priority=10\n", a)
" :sign place group={group} buffer={fname} " :sign place group={group} buffer={fname}
let a = execute('sign place group=g2 buffer=' . bnum) let a = execute('sign place group=g2 buffer=' . bnum)
call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" . call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" .
\ " line=12 id=5 group=g2 name=sign1 priority=10\n", a) \ " line=12 id=5 group=g2 name=sign1 priority=10\n", a)
" :sign place group=* buffer={fname} " :sign place group=* buffer={fname}
let a = execute('sign place group=* buffer=' . bnum) let a = execute('sign place group=* buffer=' . bnum)
call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" . call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" .
\ " line=10 id=5 name=sign1 priority=10\n" . \ " line=10 id=5 name=sign1 priority=10\n" .
\ " line=11 id=5 group=g1 name=sign1 priority=10\n" . \ " line=11 id=5 group=g1 name=sign1 priority=10\n" .
\ " line=12 id=5 group=g2 name=sign1 priority=10\n", a) \ " line=12 id=5 group=g2 name=sign1 priority=10\n", a)
" Error case: non-existing group " Error case: non-existing group
let a = execute('sign place group=xyz buffer=' . bnum) let a = execute('sign place group=xyz buffer=' . bnum)
@@ -661,19 +661,19 @@ func Test_sign_group()
" :sign place " :sign place
let a = execute('sign place') let a = execute('sign place')
call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" . call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" .
\ " line=10 id=5 name=sign1 priority=10\n", a) \ " line=10 id=5 name=sign1 priority=10\n", a)
" :sign place group={group} " :sign place group={group}
let a = execute('sign place group=g1') let a = execute('sign place group=g1')
call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" . call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" .
\ " line=11 id=5 group=g1 name=sign1 priority=10\n", a) \ " line=11 id=5 group=g1 name=sign1 priority=10\n", a)
" :sign place group=* " :sign place group=*
let a = execute('sign place group=*') let a = execute('sign place group=*')
call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" . call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" .
\ " line=10 id=5 name=sign1 priority=10\n" . \ " line=10 id=5 name=sign1 priority=10\n" .
\ " line=11 id=5 group=g1 name=sign1 priority=10\n" . \ " line=11 id=5 group=g1 name=sign1 priority=10\n" .
\ " line=12 id=5 group=g2 name=sign1 priority=10\n", a) \ " line=12 id=5 group=g2 name=sign1 priority=10\n", a)
" Test for ':sign jump' command with groups " Test for ':sign jump' command with groups
sign jump 5 group=g1 file=Xsign sign jump 5 group=g1 file=Xsign
@@ -1128,14 +1128,14 @@ func Test_sign_priority()
sign place 5 group=g2 line=10 name=sign1 priority=25 file=Xsign sign place 5 group=g2 line=10 name=sign1 priority=25 file=Xsign
let a = execute('sign place group=*') let a = execute('sign place group=*')
call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" . call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" .
\ " line=10 id=5 name=sign1 priority=30\n" . \ " line=10 id=5 name=sign1 priority=30\n" .
\ " line=10 id=5 group=g2 name=sign1 priority=25\n" . \ " line=10 id=5 group=g2 name=sign1 priority=25\n" .
\ " line=10 id=5 group=g1 name=sign1 priority=20\n", a) \ " line=10 id=5 group=g1 name=sign1 priority=20\n", a)
" Test for :sign place group={group} " Test for :sign place group={group}
let a = execute('sign place group=g1') let a = execute('sign place group=g1')
call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" . call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" .
\ " line=10 id=5 group=g1 name=sign1 priority=20\n", a) \ " line=10 id=5 group=g1 name=sign1 priority=20\n", a)
call sign_unplace('*') call sign_unplace('*')
call sign_undefine() call sign_undefine()

View File

@@ -240,7 +240,7 @@ describe('Signs', function()
:sign place | :sign place |
{9:--- Signs ---} | {9:--- Signs ---} |
{10:Signs for [NULL]:} | {10:Signs for [NULL]:} |
line=1 id=100000 name=piet priority=10 | line=1 id=100000 name=piet priority=10 |
| |
{11:Press ENTER or type command to continue}^ | {11:Press ENTER or type command to continue}^ |
]]) ]])