Skip to content

Commit

Permalink
Fix detecting text direction with astral plane character
Browse files Browse the repository at this point in the history
  • Loading branch information
amake committed Jan 29, 2025
1 parent 17adba9 commit 170ec00
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/src/util/bidi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class OrgBidiDetectionSerializer extends OrgSerializer {
void write(String str) {
if (canceled) return;

final idx = str.indexOf(UnicodeCharMatcher.bidiStrong());
final idx = UnicodeCharMatcher.bidiStrong().firstIndexIn(str);
if (idx != -1) {
canceled = true;
strongChar = str.codeUnitAt(idx);
Expand Down
5 changes: 5 additions & 0 deletions test/bidi_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ void main() {
final textDirection = node.detectTextDirection();
expect(textDirection, TextDirection.ltr);
});
test('astral plane', () {
final node = OrgPlainText('🌍');
final textDirection = node.detectTextDirection();
expect(textDirection, isNull);
});
}

0 comments on commit 170ec00

Please sign in to comment.