Handle input chunks that end within multi-byte characters

This commit is contained in:
Max Brunsfeld 2018-08-02 15:30:40 -07:00
parent 126f84aa73
commit acc937b7d7
10 changed files with 64 additions and 116 deletions

View file

@ -11,7 +11,6 @@
#include "helpers/load_language.h"
#include "helpers/random_helpers.h"
#include "helpers/read_test_entries.h"
#include "helpers/encoding_helpers.h"
#include "helpers/tree_helpers.h"
TSPoint point(uint32_t row, uint32_t column) {
@ -71,8 +70,8 @@ describe("Tree", [&]() {
for (unsigned j = 0; j < 10; j++) {
random.sleep_some();
size_t edit_position = random(utf8_char_count(input->content));
size_t deletion_size = random(utf8_char_count(input->content) - edit_position);
size_t edit_position = random(input->content.size());
size_t deletion_size = random(input->content.size() - edit_position);
string inserted_text = random.words(random(4) + 1);
TSInputEdit edit = input->replace(edit_position, deletion_size, inserted_text);