fix: fix for splitting up tokens with combined punctuation (#1828)
This commit is contained in:
parent
eaf2119d22
commit
beb0e91c07
2 changed files with 9 additions and 18 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue