fix: fix for splitting up tokens with combined punctuation (#1828)

This commit is contained in:
ggurdin 2025-02-17 16:48:39 -05:00 committed by GitHub
parent eaf2119d22
commit beb0e91c07
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 18 deletions

View file

@ -45,7 +45,6 @@ import '../../widgets/matrix.dart';
import 'package:fluffychat/utils/tor_stub.dart'
if (dart.library.html) 'package:tor_detector_web/tor_detector_web.dart';
enum PopupMenuAction {
settings,
invite,

View file

@ -241,27 +241,19 @@ class MessageTextWidget extends StatelessWidget {
// if the tokenPosition is a combination of the token and preceding / following punctuation
// split them so that only the token itself is highlighted when clicked
String start = '';
String middle = substring;
String middle = '';
String end = '';
final startSplitIndex =
(tokenPosition.tokenStart - tokenPosition.start);
final endSplitIndex = (tokenPosition.end - tokenPosition.tokenEnd);
tokenPosition.tokenStart - tokenPosition.start;
final endSplitIndex = tokenPosition.tokenEnd - tokenPosition.start;
if (tokenPosition.tokenStart != tokenPosition.start) {
start = substring.substring(0, startSplitIndex);
}
if (tokenPosition.end != tokenPosition.tokenEnd) {
end = substring.substring(endSplitIndex);
}
if (start.isNotEmpty || end.isNotEmpty) {
middle = substring.substring(
start.isEmpty ? 0 : start.length,
substring.length - (end.isEmpty ? 0 : end.length),
);
}
start = substring.substring(0, startSplitIndex);
end = substring.substring(endSplitIndex);
middle = substring.substring(
startSplitIndex,
endSplitIndex,
);
return WidgetSpan(
child: MouseRegion(