From adb1029977169ac665041e2e95613c531808875e Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Wed, 26 May 2021 02:58:18 +0200 Subject: Fix alignment of multiline messages When `weechat.look.prefix_align` is set to `none`, lines after the first in a message would not align with the first. Use the same number of spaces as the prefix for those lines, so they align with the first. --- wee_slack.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/wee_slack.py b/wee_slack.py index cec821c..e4716b4 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -259,9 +259,12 @@ class WeechatWrapper(object): return decode_from_utf8(orig_attr) # Ensure all lines sent to weechat specifies a prefix. For lines after the - # first, we want to disable the prefix, which is done by specifying a space. + # first, we want to disable the prefix, which we do by specifying the same + # number of spaces, so it aligns correctly. def prnt_date_tags(self, buffer, date, tags, message): - message = message.replace("\n", "\n \t") + prefix, _, _ = message.partition("\t") + prefix_spaces = " " * len(weechat.string_remove_color(prefix, "")) + message = message.replace("\n", "\n{}\t".format(prefix_spaces)) return self.wrap_for_utf8(self.wrapped_class.prnt_date_tags)( buffer, date, tags, message ) -- cgit