[PATCH] Fix regression in compact message formatting
Export this patch
A recent commit [1] broke mesage formatting in compact message mode.
Linkify was stripping all formatting, and the style was never passed
back before displaying it.
We cannot just rely on a DefaultStyle here because there are multiple
styles we want to apply, one per formatting span found in the IRC
message formatting.
Instead, this patch adds back the text style parameter to linkify, but
making it optional.
[1]: 6c7c51b029c9be8664c958279f632313bac5f193
---
lib/linkify.dart | 3 ++-
lib/page/buffer.dart | 5 +++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/lib/linkify.dart b/lib/linkify.dart
index 1d0b18a..5b5e13f 100644
--- a/lib/linkify.dart
+++ b/lib/linkify.dart
@@ -20,7 +20,7 @@ List<LinkifyElement> extractLinks(String text, [NetworkModel? network]) {
}
TextSpan linkify(BuildContext context, String text, {
- required TextStyle linkStyle,
+ required TextStyle linkStyle, TextStyle? textStyle
}) {
NetworkModel? network;
try {
@@ -43,6 +43,7 @@ TextSpan linkify(BuildContext context, String text, {
throw Exception('Failed to launch URL: ${link.url}');
}
},
+ style: textStyle,
linkStyle: linkStyle,
);
}
diff --git a/lib/page/buffer.dart b/lib/page/buffer.dart
index 80641ed..a8fc1c3 100644
--- a/lib/page/buffer.dart
+++ b/lib/page/buffer.dart
@@ -428,7 +428,7 @@ class _CompactMessageItem extends StatelessWidget {
var textStyle = TextStyle(color: Theme.of(context).textTheme.bodyText1!.color);
List<TextSpan> textSpans;
- if (ctcp != null && ctcp.cmd == 'ACTION') {
+ if (ctcp != null) {
textStyle = textStyle.apply(fontStyle: FontStyle.italic);
if (ctcp.cmd == 'ACTION') {
@@ -441,7 +441,8 @@ class _CompactMessageItem extends StatelessWidget {
}
textSpans = textSpans.map((span) {
- return linkify(context, span.text!, linkStyle: TextStyle(decoration: TextDecoration.underline));
+ var linkStyle = span.style!.apply(decoration: TextDecoration.underline);
+ return linkify(context, span.text!, textStyle: span.style!, linkStyle: linkStyle);
}).toList();
List<Widget> stack = [];
base-commit: c4df7fe91caae2ba0f4d3af0df8fb62757556790
--
2.17.1
NACK, this shouldn't be needed. We should be able to apply a
DefaultTextStyle to the container instead.