Shift selects on last/first line

This commit is contained in:
Krzosa Karol
2025-05-09 10:56:17 +02:00
parent 3180625a41
commit 1590f12b43
2 changed files with 13 additions and 5 deletions

View File

@@ -293,8 +293,12 @@ Caret MoveCaret(Buffer *buffer, Caret it, int direction, bool ctrl = false, bool
Int pos = GetPrevEmptyLineStart(buffer, it.range.min);
it = MakeCaret(pos);
} else if (shift) {
if (PosToLine(buffer, front) == 0) {
it = SetFront(it, 0);
} else {
Int pos = OffsetByLine(buffer, front, -1);
it = SetFront(it, pos);
}
} else {
if (range_size == 0) {
Int pos = OffsetByLine(buffer, it.range.min, -1);
@@ -312,8 +316,12 @@ Caret MoveCaret(Buffer *buffer, Caret it, int direction, bool ctrl = false, bool
Int pos = GetNextEmptyLineStart(buffer, it.range.max);
it = MakeCaret(pos);
} else if (shift) {
if (LastLine(buffer) == PosToLine(buffer, front)) {
it = SetFront(it, buffer->len);
} else {
Int pos = OffsetByLine(buffer, front, 1);
it = SetFront(it, pos);
}
} else {
if (range_size == 0) {
Int pos = OffsetByLine(buffer, it.range.max, 1);