From bc0ab5dd6bdcf80e1bf72d7b0acce9614b71decd Mon Sep 17 00:00:00 2001 From: login000 <34250284+login000@users.noreply.github.com> Date: Tue, 24 Sep 2019 02:01:34 +1000 Subject: Stylistic update to "Last messages" When there are fewer than messages in total, and one runs "tcoin -m ", an extra newline was shown between "Last messages:" and the actual messages. This commit fixes that by checking if the first character in the actual messages is a newline and putting one more newline only if it isn't (instead of always). --- tcoin.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tcoin.cpp b/tcoin.cpp index 5aad518..edc5ff7 100644 --- a/tcoin.cpp +++ b/tcoin.cpp @@ -491,7 +491,9 @@ void show_messages_tail(const char* username, int lineCount) continue; //we're counting cutting off a '\n ' (and '\n\n') as zero (and one) newline cut off because "\n \_message>\n\n" is one message --newlineCount; } - std::cout << "Last " << lineCount << " Messages:\n\n"; + std::cout << "Last " << lineCount << " Messages:\n"; + if(*(start) != '\n') //if it starts with a newline, don't put another one + std::cout << "\n"; std::vector::iterator end = remove(start, buffer.end(), '\r'); std::cout << std::string(start, end); if(*(end-2) != '\n') //if it ends with two newlines, don't put another one -- cgit