Drawing selection and overlapping selections

This commit is contained in:
Krzosa Karol
2024-06-23 10:05:54 +02:00
parent 10afbd3e4f
commit b76d825f55
3 changed files with 64 additions and 18 deletions

View File

@@ -349,6 +349,7 @@ LineAndColumn FindLineAndColumn(Buffer &buffer, int64_t pos) {
result.column = 1;
result.line = FindLine(buffer, pos);
for (BufferIter iter = Iterate(buffer, result.line.range); IsValid(iter); Advance(&iter)) {
// @todo: make sure we handle when there is invalid unicode in the stream
if (iter.pos == pos) {
result.column = iter.codepoint_index;
break;
@@ -395,7 +396,7 @@ int64_t Seek(Buffer &buffer, int64_t pos, int64_t direction = ITERATE_FORWARD) {
bool seek_whitespace = standing_on_whitespace == false;
bool seek_word = standing_on_whitespace;
int64_t result = max;
int64_t result = direction == ITERATE_BACKWARD ? 0 : buffer.len;
BufferIter iter = Iterate(buffer, {min, max}, direction);
int64_t prev_pos = iter.pos;
for (; IsValid(iter); Advance(&iter)) {