Fix in the hack index -> character; all of those things need to be revisited for robustness and performance!

This commit is contained in:
Allen Webster 2019-10-08 13:39:35 -07:00
parent 2f68a95fd5
commit 640481de56
1 changed files with 21 additions and 13 deletions

View File

@ -1016,6 +1016,13 @@ buffer_layout_character_from_pos(Buffer_Layout_Item_List list, i64 index){
i64 result = 0;
i64 character_count = 0;
i64 prev_index = -1;
if (index <= list.index_range.first){
result = 0;
}
else if (index > list.index_range.one_past_last){
result = list.character_count - 1;
}
else{
for (Buffer_Layout_Item_Block *node = list.first;
node != 0;
node = node->next){
@ -1032,6 +1039,7 @@ buffer_layout_character_from_pos(Buffer_Layout_Item_List list, i64 index){
}
}
}
}
double_break:;
return(result);
}