Improve mouse scrolling
This commit is contained in:
@@ -489,15 +489,23 @@ Line GetLineByIndex(Buffer &buffer, int64_t line) {
|
||||
|
||||
Line FindLine(Buffer &buffer, int64_t pos) {
|
||||
Line result = {};
|
||||
|
||||
For(buffer.lines) {
|
||||
bool found_last = (pos == it.min && pos == it.max); // @end_of_buffer
|
||||
bool found = pos >= it.min && pos < it.max;
|
||||
if (found || found_last) {
|
||||
if (pos >= it.min && pos < it.max) {
|
||||
result = {buffer.lines.get_index(it), it, it.max};
|
||||
if (it.max > it.min && GetChar(buffer, it.max - 1) == '\n') result.max_without_new_line -= 1;
|
||||
break;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
if (pos == buffer.len) { // @end of buffer
|
||||
auto &it = buffer.lines[buffer.lines.len - 1];
|
||||
Assert(it.max == buffer.len);
|
||||
result = {buffer.lines.get_index(it), it, it.max};
|
||||
if (it.max > it.min && GetChar(buffer, it.max - 1) == '\n') result.max_without_new_line -= 1;
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user