diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2022-07-02 21:10:48 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2022-07-02 21:10:48 +0200 |
commit | 1c7b431bc8118207c7b54c8edfa0e5faab032c0d (patch) | |
tree | 420c97be5f4ab589ce253d3e6e6110b31ae9bfc7 | |
parent | 749bc2692636f3427267fd918c4eaf4c1d52abbe (diff) | |
download | weechat-1c7b431bc8118207c7b54c8edfa0e5faab032c0d.zip |
api: run hook_print callback also on empty messages
-rw-r--r-- | ChangeLog.adoc | 1 | ||||
-rw-r--r-- | ReleaseNotes.adoc | 9 | ||||
-rw-r--r-- | src/core/hook/wee-hook-print.c | 2 | ||||
-rw-r--r-- | tests/tests.cpp | 4 | ||||
-rw-r--r-- | tests/unit/plugins/irc/test-irc-protocol.cpp | 8 |
5 files changed, 17 insertions, 7 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc index d1465dc1b..a52c86037 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -33,6 +33,7 @@ New features:: Bug fixes:: * core: fix bad window size on startup with some terminals like https://github.com/kovidgoyal/kitty[kitty] (issue #1769) + * api: run hook_print callback also on empty messages * buflist: fix memory leak when reading config and changing option buflist.look.sort * irc: remove channel from autojoin option when manually closing a buffer with `/buffer close` or `/close` * irc: fix add of channel to autojoin option when joining a channel with a buffer still opened diff --git a/ReleaseNotes.adoc b/ReleaseNotes.adoc index 77ee0e529..7f93e8e33 100644 --- a/ReleaseNotes.adoc +++ b/ReleaseNotes.adoc @@ -20,6 +20,15 @@ https://weechat.org/files/changelog/ChangeLog-devel.html[ChangeLog] [[v3.6]] == Version 3.6 (under dev) +[[v3.6_hook_print_empty_messages]] +=== Hook print on empty messages + +The "hook_print" callback is now called even when an empty message is displayed +(with or without prefix). + +This was a bug, but is mentioned here just in case some scripts callbacks +would be surprised to be called with such empty messages. + [[v3.6_trigger_beep]] === Default trigger "beep" diff --git a/src/core/hook/wee-hook-print.c b/src/core/hook/wee-hook-print.c index b21ba088c..25986ebb5 100644 --- a/src/core/hook/wee-hook-print.c +++ b/src/core/hook/wee-hook-print.c @@ -126,7 +126,7 @@ hook_print_exec (struct t_gui_buffer *buffer, struct t_gui_line *line) if (!weechat_hooks[HOOK_TYPE_PRINT]) return; - if (!line->data->message || !line->data->message[0]) + if (!line->data->message) return; prefix_no_color = (line->data->prefix) ? diff --git a/tests/tests.cpp b/tests/tests.cpp index 6254c0299..bf16dfea5 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -140,7 +140,7 @@ test_print_cb (const void *pointer, void *data, struct t_gui_buffer *buffer, "%s: \"%s%s%s\"", buffer_full_name, (prefix && prefix[0]) ? prefix : "", - (prefix && prefix[0]) ? " " : "", + (prefix && prefix[0] && message && message[0]) ? " " : "", (message && message[0]) ? message : ""); arraylist_add (recorded_messages, strdup (str_recorded)); } @@ -150,7 +150,7 @@ test_print_cb (const void *pointer, void *data, struct t_gui_buffer *buffer, { printf ("%s%s%s\n", /* with color: "\33[34m%s%s%s\33[0m\n" */ (prefix && prefix[0]) ? prefix : "", - (prefix && prefix[0]) ? " " : "", + (prefix && prefix[0] && message && message[0]) ? " " : "", (message && message[0]) ? message : ""); } diff --git a/tests/unit/plugins/irc/test-irc-protocol.cpp b/tests/unit/plugins/irc/test-irc-protocol.cpp index a1a5ac5c4..d6c4ca47e 100644 --- a/tests/unit/plugins/irc/test-irc-protocol.cpp +++ b/tests/unit/plugins/irc/test-irc-protocol.cpp @@ -2048,7 +2048,7 @@ TEST(IrcProtocolWithServer, 001_empty) CHECK_ERROR_PARAMS("001", 0, 1); RECV(":server 001 alice"); - CHECK_NO_MSG; + CHECK_SRV("--"); LONGS_EQUAL(1, ptr_server->is_connected); STRCMP_EQUAL("alice", ptr_server->nick); } @@ -2693,7 +2693,7 @@ TEST(IrcProtocolWithServer, 323) CHECK_ERROR_PARAMS("323", 0, 1); RECV(":server 323 alice"); - CHECK_NO_MSG; + CHECK_SRV("--"); RECV(":server 323 alice end"); CHECK_SRV("-- end"); RECV(":server 323 alice :End of /LIST"); @@ -3999,7 +3999,7 @@ TEST(IrcProtocolWithServer, 732) CHECK_ERROR_PARAMS("732", 0, 1); RECV(":server 732 alice"); - CHECK_NO_MSG; + CHECK_SRV("--"); RECV(":server 732 alice :nick1!user1@host1,nick2!user2@host2"); CHECK_SRV("-- nick1!user1@host1,nick2!user2@host2"); } @@ -4018,7 +4018,7 @@ TEST(IrcProtocolWithServer, 733) CHECK_ERROR_PARAMS("733", 0, 1); RECV(":server 733 alice"); - CHECK_NO_MSG; + CHECK_SRV("--"); RECV(":server 733 alice end"); CHECK_SRV("-- end"); RECV(":server 733 alice :End of MONITOR list"); |