summaryrefslogtreecommitdiff
path: root/buffer.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2023-03-02 10:52:08 -0500
committerpommicket <pommicket@gmail.com>2023-03-02 10:52:08 -0500
commit4aebef26deaed5d26fe450193da044f7734051e1 (patch)
tree1bc66ba0db2e41bb78241eda9bf14466e8538f37 /buffer.c
parenteddcc7e8c6c02970ac658024b3a8c6b5f416c8a5 (diff)
:previous-position
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/buffer.c b/buffer.c
index 8371c7c..50bdbe7 100644
--- a/buffer.c
+++ b/buffer.c
@@ -1119,12 +1119,22 @@ void buffer_cursor_move_to_pos(TextBuffer *buffer, BufferPos pos) {
if (buffer_pos_eq(buffer->cursor_pos, pos)) {
return;
}
+
+ if (labs((long)buffer->cursor_pos.line - (long)pos.line) > 20) {
+ // if this is a big jump, update the previous cursor pos
+ buffer->prev_cursor_pos = buffer->cursor_pos;
+ }
+
buffer->cursor_pos = pos;
buffer->selection = false;
buffer_scroll_to_cursor(buffer);
signature_help_retrigger(buffer->ted);
}
+void buffer_cursor_move_to_prev_pos(TextBuffer *buffer) {
+ buffer_cursor_move_to_pos(buffer, buffer->prev_cursor_pos);
+}
+
i64 buffer_cursor_move_left(TextBuffer *buffer, i64 by) {
BufferPos cur_pos = buffer->cursor_pos;
i64 ret = 0;