From 94ca8bffaf904037f04781350d928a7b306377b2 Mon Sep 17 00:00:00 2001 From: tastytea Date: Sun, 29 Dec 2019 00:10:13 +0100 Subject: [PATCH] Don't cut in the middle of a word. --- src/mastoapi.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/mastoapi.cpp b/src/mastoapi.cpp index cbffbe8..15fca41 100644 --- a/src/mastoapi.cpp +++ b/src/mastoapi.cpp @@ -70,6 +70,14 @@ void MastoAPI::post_item(const Item &item) if ((len + len_append) > len_max) { status.resize(len_max - len_append - omission.size()); + + // Don't cut in the middle of a word. + const auto pos = status.rfind(' '); + if (pos != string::npos) + { + status.resize(status.size() - pos); + } + status.append(omission); }