mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
test: next runes
This commit is contained in:
parent
c554720dff
commit
b5ecd7dedc
@ -477,7 +477,7 @@ class Delta extends Iterable<TextOperation> {
|
||||
|
||||
int prevRunePosition(int pos) {
|
||||
if (pos == 0) {
|
||||
return pos;
|
||||
return pos - 1;
|
||||
}
|
||||
_rawString ??=
|
||||
_operations.whereType<TextInsert>().map((op) => op.content).join();
|
||||
@ -498,7 +498,7 @@ class Delta extends Iterable<TextOperation> {
|
||||
}
|
||||
}
|
||||
|
||||
return pos;
|
||||
return stringContent.length;
|
||||
}
|
||||
|
||||
String toRawString() {
|
||||
|
@ -279,9 +279,35 @@ void main() {
|
||||
expect(delta, expected);
|
||||
});
|
||||
});
|
||||
test("stringIndexes", () {
|
||||
final indexes = stringIndexes('😊');
|
||||
expect(indexes[0], 0);
|
||||
expect(indexes[1], 0);
|
||||
group('runes', () {
|
||||
test("stringIndexes", () {
|
||||
final indexes = stringIndexes('😊');
|
||||
expect(indexes[0], 0);
|
||||
expect(indexes[1], 0);
|
||||
});
|
||||
test("next rune 1", () {
|
||||
final delta = Delta()..insert('😊');
|
||||
expect(delta.nextRunePosition(0), 2);
|
||||
});
|
||||
test("next rune 2", () {
|
||||
final delta = Delta()..insert('😊a');
|
||||
expect(delta.nextRunePosition(0), 2);
|
||||
});
|
||||
test("next rune 3", () {
|
||||
final delta = Delta()..insert('😊陈');
|
||||
expect(delta.nextRunePosition(2), 3);
|
||||
});
|
||||
test("prev rune 1", () {
|
||||
final delta = Delta()..insert('😊陈');
|
||||
expect(delta.prevRunePosition(2), 0);
|
||||
});
|
||||
test("prev rune 2", () {
|
||||
final delta = Delta()..insert('😊');
|
||||
expect(delta.prevRunePosition(2), 0);
|
||||
});
|
||||
test("prev rune 3", () {
|
||||
final delta = Delta()..insert('😊');
|
||||
expect(delta.prevRunePosition(0), -1);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user