* tide: move looping of cursor movements into selmoveby
* all: eliminate multiple return statements and other lint
* tide: byrune, byword, byline functions should be hidden in buf.c
-* tide: column tracking should be hidden in buf.c
* tide: buf_findstr has an infinite loop condition
* tide: refactor undo/redo api in view.c
if (buf_selsz(buf) && !extsel)
{
buf_selclr(buf, move);
- if (bything == BY_LINE && move < 0)
+ if (bything == BY_LINE)
{
buf->selection.end = buf_moveby(buf, bything, buf->selection.end, move);
}
CHECK(5 == TestBuf.selection.end);
CHECK(10 == TestBuf.selection.col);
}
+
+ TEST(buf_selmove should clear selection and move cursor up one line)
+ {
+ set_buffer_text("aa\nbb\ncc\n");
+ TestBuf.selection = (Sel){ .beg = 4, .end = 5, .col = 1 };
+ buf_selmove(&TestBuf, false, UP, BY_LINE);
+ CHECK(1 == TestBuf.selection.beg);
+ CHECK(1 == TestBuf.selection.end);
+ CHECK(1 == TestBuf.selection.col);
+ }
+
+ TEST(buf_selmove should clear selection and move cursor down one line)
+ {
+ set_buffer_text("aa\nbb\ncc\n");
+ TestBuf.selection = (Sel){ .beg = 4, .end = 5, .col = 2 };
+ buf_selmove(&TestBuf, false, DOWN, BY_LINE);
+ CHECK(8 == TestBuf.selection.beg);
+ CHECK(8 == TestBuf.selection.end);
+ CHECK(2 == TestBuf.selection.col);
+ }
}