~emersion/goguma-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH v2] page/buffer: Make invisible compact message spacing unselectable

Details
Message ID
<20240424195839.238990-1-delthas@dille.cc>
DKIM signature
pass
Download raw message
Patch: +22 -10
We're building compact message items by writing an invisible prefix
(stacked with an actual username), then the actual message, then
an invisible suffix (stack with an actual timestamp).

Currenty selecting a compact message text results in selecting the
invisible prefixes and suffixes as well, which results in unexpected
data being selected.

This patch makes these invisible hacky spacings unselectable so that
only the actual message can be selected and copied in the list.
---
Using SelectionArea gives better behavior when selecting the edges
of the line.

 lib/page/buffer.dart | 32 ++++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/lib/page/buffer.dart b/lib/page/buffer.dart
index 56cc234..323b960 100644
--- a/lib/page/buffer.dart
+++ b/lib/page/buffer.dart
@@ -635,7 +635,7 @@ class _CompactMessageItem extends StatelessWidget {
		}).toList();

		List<Widget> stack = [];
		List<TextSpan> content = [];
		List<InlineSpan> content = [];

		if (!prevMsgSameSender) {
			var colorSwatch = Colors.primaries[sender.hashCode % Colors.primaries.length];
@@ -646,9 +646,14 @@ class _CompactMessageItem extends StatelessWidget {
				left: 0,
				child: Text(sender, style: senderStyle),
			));
			content.add(TextSpan(
				text: sender,
				style: senderStyle.apply(color: Color(0x00000000)),
			content.add(WidgetSpan(
				child: SelectionContainer.disabled(
					child: Text(
						sender,
						style: senderStyle.apply(color: Color(0x00000000)),
						semanticsLabel: '',  // Make screen reader quiet
					),
				),
			));
		}

@@ -665,17 +670,24 @@ class _CompactMessageItem extends StatelessWidget {
				right: 0,
				child: Text(timeText, style: timeStyle),
			));
			content.add(TextSpan(
				text: timeText,
				style: timeStyle.apply(color: Color(0x00000000)),
			content.add(WidgetSpan(
				child: SelectionContainer.disabled(
					child: Text(
						timeText,
						style: timeStyle.apply(color: Color(0x00000000)),
						semanticsLabel: '',  // Make screen reader quiet
					),
				),
			));
		}

		stack.add(Container(
			margin: EdgeInsets.only(left: 4),
			child: SelectableText.rich(
				TextSpan(
					children: content,
			child: SelectionArea(
				child: Text.rich(
					TextSpan(
						children: content,
					),
				),
			),
		));

base-commit: 38c1594530bf34129b3b20353ac614973a5b9d26
-- 
2.44.0
Details
Message ID
<d1leV0SkNYt3WtxVBmnL8RE_Z6J-9bnXGNg-atTi1O8dcSgsS_Zr6ASgxEyYlT4ylqPtp2VZbF4Jv12YFs_vPmh1Nz_2ZfVE_7jltc2RRLQ=@emersion.fr>
In-Reply-To
<20240424195839.238990-1-delthas@dille.cc> (view parent)
DKIM signature
pass
Download raw message
Pushed, thanks!
Reply to thread Export thread (mbox)