diff options
author | Bram Moolenaar <Bram@vim.org> | 2016-04-14 17:16:22 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2016-04-14 17:16:22 +0200 |
commit | 451f849fd6282a4facd4f0f58af62837443fb5a6 (patch) | |
tree | dcadb8161d6fc31d17394ce778067fd4625e2ddd /src | |
parent | 0f518a8f4d4be4cac10389680f6bd5e3781f94b0 (diff) |
patch 7.4.1735v7.4.1735
Problem: It is not possible to only see part of the message history. It is
not possible to clear messages.
Solution: Add a count to ":messages" and a clear argument. (Yasuhiro
Matsumoto)
Diffstat (limited to 'src')
-rw-r--r-- | src/ex_cmds.h | 2 | ||||
-rw-r--r-- | src/message.c | 34 | ||||
-rw-r--r-- | src/testdir/test_alot.vim | 1 | ||||
-rw-r--r-- | src/testdir/test_messages.vim | 42 | ||||
-rw-r--r-- | src/version.c | 2 |
5 files changed, 79 insertions, 2 deletions
diff --git a/src/ex_cmds.h b/src/ex_cmds.h index 34defea44e..409533112c 100644 --- a/src/ex_cmds.h +++ b/src/ex_cmds.h @@ -886,7 +886,7 @@ EX(CMD_menutranslate, "menutranslate", ex_menutranslate, EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN, ADDR_LINES), EX(CMD_messages, "messages", ex_messages, - TRLBAR|CMDWIN, + EXTRA|TRLBAR|RANGE|CMDWIN, ADDR_LINES), EX(CMD_mkexrc, "mkexrc", ex_mkrc, BANG|FILE1|TRLBAR|CMDWIN, diff --git a/src/message.c b/src/message.c index 099c3aa754..b24013e41d 100644 --- a/src/message.c +++ b/src/message.c @@ -770,6 +770,22 @@ ex_messages(exarg_T *eap UNUSED) { struct msg_hist *p; char_u *s; + int c = 0; + + if (STRCMP(eap->arg, "clear") == 0) + { + int keep = eap->addr_count == 0 ? 0 : eap->line2; + + while (msg_hist_len > keep) + (void)delete_first_msg(); + return; + } + + if (*eap->arg != NUL) + { + EMSG(_(e_invarg)); + return; + } msg_hist_off = TRUE; @@ -779,7 +795,23 @@ ex_messages(exarg_T *eap UNUSED) _("Messages maintainer: Bram Moolenaar <Bram@vim.org>"), hl_attr(HLF_T)); - for (p = first_msg_hist; p != NULL && !got_int; p = p->next) + p = first_msg_hist; + + if (eap->addr_count != 0) + { + /* Count total messages */ + for (; p != NULL && !got_int; p = p->next) + c++; + + c -= eap->line2; + + /* Skip without number of messages specified */ + for (p = first_msg_hist; p != NULL && !got_int && c > 0; + p = p->next, c--); + } + + /* Display what was not skipped. */ + for (; p != NULL && !got_int; p = p->next) if (p->msg != NULL) msg_attr(p->msg, p->attr); diff --git a/src/testdir/test_alot.vim b/src/testdir/test_alot.vim index 7f9a1a78fe..d393fe78a4 100644 --- a/src/testdir/test_alot.vim +++ b/src/testdir/test_alot.vim @@ -17,6 +17,7 @@ source test_join.vim source test_lispwords.vim source test_matchstrpos.vim source test_menu.vim +source test_messages.vim source test_partial.vim source test_reltime.vim source test_searchpos.vim diff --git a/src/testdir/test_messages.vim b/src/testdir/test_messages.vim new file mode 100644 index 0000000000..4d7e41130c --- /dev/null +++ b/src/testdir/test_messages.vim @@ -0,0 +1,42 @@ +" Tests for :messages + +function Test_messages() + let oldmore = &more + try + set nomore + + let arr = map(range(10), '"hello" . v:val') + for s in arr + echomsg s | redraw + endfor + let result = '' + + redir => result + 2messages | redraw + redir END + + " get last two messages + let msg = split(result, "\n")[1:][-2:] + call assert_equal(["hello8", "hello9"], msg) + + " clear messages without last one + 1messages clear + redir => result + redraw | 1messages + redir END + " get last last message + let msg = split(result, "\n")[1:][-1:] + call assert_equal(['hello9'], msg) + + " clear all messages + messages clear + redir => result + redraw | 1messages + redir END + " get last last message + let msg = split(result, "\n")[1:][-1:] + call assert_equal([], msg) + finally + let &more = oldmore + endtry +endfunction diff --git a/src/version.c b/src/version.c index a013661c5a..93c74d3731 100644 --- a/src/version.c +++ b/src/version.c @@ -749,6 +749,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1735, +/**/ 1734, /**/ 1733, |