1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-29 14:26:39 +02:00

core: allow command /toggle to create option before setting the value, if allowed in the section (closes #1837)

This commit is contained in:
Sébastien Helleu
2022-10-12 21:29:38 +02:00
parent f97b74cae8
commit 7d2e8b9143
2 changed files with 20 additions and 5 deletions
+4
View File
@@ -18,6 +18,10 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
[[v3.8]]
== Version 3.8 (under dev)
New features::
* core: allow command `/toggle` to create option before setting the value, if allowed in the section (issue #1837)
Bug fixes::
* core: fix context info in buffers with free content (issue #1832)
+16 -5
View File
@@ -6314,11 +6314,22 @@ COMMAND_CALLBACK(toggle)
config_file_search_with_string (argv[1], NULL, NULL, &ptr_option, NULL);
if (!ptr_option)
{
gui_chat_printf (NULL,
_("%sOption \"%s\" not found"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
argv[1]);
return WEECHAT_RC_OK;
/* try to create option with empty value if not existing */
rc = config_file_option_set_with_string (argv[1], "");
if ((rc == WEECHAT_CONFIG_OPTION_SET_OK_CHANGED) ||
(rc == WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE))
{
config_file_search_with_string (argv[1], NULL, NULL, &ptr_option,
NULL);
}
if (!ptr_option)
{
gui_chat_printf (NULL,
_("%sOption \"%s\" not found"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
argv[1]);
return WEECHAT_RC_OK;
}
}
if ((ptr_option->type != CONFIG_OPTION_TYPE_BOOLEAN)