Repository :
https://github.com/FarGroup/FarManager
On branch : master
Link :
https://github.com/FarGroup/FarManager/commit/2ef1dd1c474d89e2487fc08176b880f82aa84cba
>---------------------------------------------------------------
commit 2ef1dd1c474d89e2487fc08176b880f82aa84cba
Author: Alex Alabuzhev <
alab...@gmail.com>
Date: Sun Sep 20 09:21:18 2026 +0100
Clarify Message logic in corner cases
>---------------------------------------------------------------
2ef1dd1c474d89e2487fc08176b880f82aa84cba
far/changelog | 5 +++++
far/macroapi.cpp | 15 ++++++++++++---
far/plugapi.cpp | 10 ++++++++--
far/vbuild.m4 | 2 +-
4 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/far/changelog b/far/changelog
index 207d4ad38..b13bafce7 100644
--- a/far/changelog
+++ b/far/changelog
@@ -1,3 +1,8 @@
+--------------------------------------------------------------------------------
+drkns 2026-09-20 09:20:27+01:00 - build 6736
+
+1. Clarify Message logic in corner cases.
+
--------------------------------------------------------------------------------
drkns 2026-09-18 21:47:54+01:00 - build 6735
diff --git a/far/macroapi.cpp b/far/macroapi.cpp
index e69b5729c..dae39b401 100644
--- a/far/macroapi.cpp
+++ b/far/macroapi.cpp
@@ -76,6 +76,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "platform.memory.hpp"
// Common:
+#include "common/enum_substrings.hpp"
#include "common/from_string.hpp"
#include "common/scope_exit.hpp"
#include "common/uuid.hpp"
@@ -1863,13 +1864,21 @@ void FarMacroApi::msgBoxFunc() const
auto Flags = static_cast<DWORD>(Params[2].asInteger());
Flags&=~(FMSG_KEEPBACKGROUND|FMSG_ERRORTYPE);
- Flags|=FMSG_ALLINONE;
if (!extract_integer<WORD, 1>(Flags) || extract_integer<WORD, 1>(Flags) > extract_integer<WORD, 1>(FMSG_MB_RETRYCANCEL))
Flags|=FMSG_MB_OK;
- const auto TempBuf = concat(title, L'\n', text);
- const auto Result = pluginapi::apiMessageFn(&FarUuid, &FarUuid, Flags, nullptr, std::bit_cast<const wchar_t* const*>(TempBuf.c_str()), 0, 0) + 1;
+ std::vector<string> Items;
+ Items.emplace_back(title);
+
+ for (const auto& i: enum_tokens(text, L"\n"sv))
+ Items.emplace_back(i);
+
+ std::vector<const wchar_t*> RawItems;
+ RawItems.reserve(Items.size());
+ std::ranges::transform(Items, std::back_inserter(RawItems), [](const auto& Str){ return Str.c_str(); });
+
+ const auto Result = pluginapi::apiMessageFn(&FarUuid, &FarUuid, Flags, nullptr, RawItems.data(), RawItems.size(), 0) + 1;
PushValue(Result);
}
diff --git a/far/plugapi.cpp b/far/plugapi.cpp
index 64792e410..a3c9fdf07 100644
--- a/far/plugapi.cpp
+++ b/far/plugapi.cpp
@@ -1215,13 +1215,19 @@ intptr_t WINAPI apiMessageFn(const UUID* PluginId, const UUID* Id, unsigned long
string_view StrItems = std::bit_cast<const wchar_t*>(Items);
// Plugins expect that the trailing \n is ignored here, even though it's not promised anywhere.
+ bool TrailingNewLine = false;
if (StrItems.ends_with(L'\n'))
+ {
StrItems.remove_suffix(1);
+ TrailingNewLine = true;
+ }
for (const auto& i: enum_tokens(StrItems, L"\n"sv))
- {
Strings.emplace_back(i);
- }
+
+ if (Strings.size() == 1 && TrailingNewLine)
+ Strings.emplace_back();
+
AssignStrings(std::move(Strings));
}
else
diff --git a/far/vbuild.m4 b/far/vbuild.m4
index 2121a37ec..a153da9df 100644
--- a/far/vbuild.m4
+++ b/far/vbuild.m4
@@ -1 +1 @@
-6735
+6736