Fix in the hack index -> character; all of those things need to be revisited for robustness and performance!
This commit is contained in:
parent
2f68a95fd5
commit
640481de56
|
@ -1016,19 +1016,27 @@ buffer_layout_character_from_pos(Buffer_Layout_Item_List list, i64 index){
|
||||||
i64 result = 0;
|
i64 result = 0;
|
||||||
i64 character_count = 0;
|
i64 character_count = 0;
|
||||||
i64 prev_index = -1;
|
i64 prev_index = -1;
|
||||||
for (Buffer_Layout_Item_Block *node = list.first;
|
if (index <= list.index_range.first){
|
||||||
node != 0;
|
result = 0;
|
||||||
node = node->next){
|
}
|
||||||
Buffer_Layout_Item *item = node->items;
|
else if (index > list.index_range.one_past_last){
|
||||||
i64 count = node->count;
|
result = list.character_count - 1;
|
||||||
for (i64 i = 0; i < count; i += 1, item += 1){
|
}
|
||||||
if (item->index == index){
|
else{
|
||||||
result = character_count;
|
for (Buffer_Layout_Item_Block *node = list.first;
|
||||||
goto double_break;
|
node != 0;
|
||||||
}
|
node = node->next){
|
||||||
if (item->index != prev_index){
|
Buffer_Layout_Item *item = node->items;
|
||||||
prev_index = item->index;
|
i64 count = node->count;
|
||||||
character_count += 1;
|
for (i64 i = 0; i < count; i += 1, item += 1){
|
||||||
|
if (item->index == index){
|
||||||
|
result = character_count;
|
||||||
|
goto double_break;
|
||||||
|
}
|
||||||
|
if (item->index != prev_index){
|
||||||
|
prev_index = item->index;
|
||||||
|
character_count += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue