aboutsummaryrefslogtreecommitdiff
path: root/view.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-12-05 23:11:10 +0100
committerMarc André Tanner <mat@brain-dump.org>2016-12-05 23:11:10 +0100
commit6e2bfdc1ac0c9b2942f6cfac418e8a527752ae11 (patch)
treec24e79af749d33ccb2c93e2212cf19d03ba0af76 /view.c
parent05f0364090c54f9c1f91e72e08348e08f04de7e6 (diff)
downloadvis-6e2bfdc1ac0c9b2942f6cfac418e8a527752ae11.tar.gz
vis-6e2bfdc1ac0c9b2942f6cfac418e8a527752ae11.tar.xz
view: make cursor placement more robust
Reject invalid cursor positions.
Diffstat (limited to 'view.c')
-rw-r--r--view.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/view.c b/view.c
index 331ea3d..126e9f7 100644
--- a/view.c
+++ b/view.c
@@ -1164,6 +1164,11 @@ void view_cursors_scroll_to(Cursor *c, size_t pos) {
void view_cursors_to(Cursor *c, size_t pos) {
View *view = c->view;
+ if (pos == EPOS)
+ return;
+ size_t size = text_size(view->text);
+ if (pos > size)
+ pos = size;
if (c->view->cursor == c) {
/* make sure we redraw changes to the very first character of the window */
if (view->start == pos)