From 36ffff96bec4ca61b6190446a9a7ddc6ce27f293 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 22 Jul 2015 23:24:20 +0100 Subject: [PATCH] Avoid copying selection before the first line --- src/normal.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/normal.cc b/src/normal.cc index af2553e1..38cfab0e 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -994,7 +994,8 @@ void copy_selections_on_next_lines(Context& context, NormalParams params) const LineCount anchor_line = anchor.line + offset; const LineCount cursor_line = cursor.line + offset; - if (anchor_line >= buffer.line_count() or cursor_line >= buffer.line_count()) + if (anchor_line < 0 or cursor_line < 0 or + anchor_line >= buffer.line_count() or cursor_line >= buffer.line_count()) continue; ByteCount anchor_byte = get_byte_to_column(buffer, tabstop, {anchor_line, anchor_col});