fix out of bounds on text delete
parent
f602c3a493
commit
f2a0c006f3
|
@ -1,2 +1,4 @@
|
||||||
bin/
|
bin/
|
||||||
**/target
|
**/target
|
||||||
|
**/*.xcodeproj
|
||||||
|
**/*.DS_Store
|
||||||
|
|
|
@ -902,14 +902,21 @@ delete_content :: proc(buffer: ^FileBuffer, amount: int) {
|
||||||
if len(content_slice_ptr^) == 1 {
|
if len(content_slice_ptr^) == 1 {
|
||||||
// move cursor to previous content_slice so we can delete the current one
|
// move cursor to previous content_slice so we can delete the current one
|
||||||
iterate_file_buffer_reverse(&it);
|
iterate_file_buffer_reverse(&it);
|
||||||
runtime.ordered_remove(&buffer.content_slices, it.cursor.index.slice_index+1);
|
|
||||||
} else {
|
if it.hit_end {
|
||||||
|
runtime.ordered_remove(&buffer.content_slices, it.cursor.index.slice_index);
|
||||||
|
} else {
|
||||||
|
runtime.ordered_remove(&buffer.content_slices, it.cursor.index.slice_index+1);
|
||||||
|
}
|
||||||
|
} else if !it.hit_end {
|
||||||
iterate_file_buffer_reverse(&it);
|
iterate_file_buffer_reverse(&it);
|
||||||
content_slice_ptr^ = content_slice_ptr^[:len(content_slice_ptr^)-1];
|
content_slice_ptr^ = content_slice_ptr^[:len(content_slice_ptr^)-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
iterate_file_buffer(&it);
|
if !it.hit_end {
|
||||||
|
iterate_file_buffer(&it);
|
||||||
|
}
|
||||||
buffer.cursor = it.cursor;
|
buffer.cursor = it.cursor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue