From 9650e5ff365e18b0b8d8b33c0fa0bd2bb0deeac6 Mon Sep 17 00:00:00 2001 From: eidheim Date: Mon, 9 Jan 2017 20:44:18 +0100 Subject: [PATCH] Fixes Control-Up when first line contains only one character. Previously, the cursor stopped at the line before. --- src/source.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/source.cc b/src/source.cc index 3b8b29f..a277dd6 100644 --- a/src/source.cc +++ b/src/source.cc @@ -1370,8 +1370,9 @@ bool Source::View::on_key_press_event(GdkEventKey* key) { iter.backward_char(); bool empty_line=false; bool text_found=false; + bool move_to_start=false; for(;;) { - if(!iter || iter.is_start()) + if(!iter) break; if(iter.ends_line()) empty_line=true; @@ -1381,9 +1382,13 @@ bool Source::View::on_key_press_event(GdkEventKey* key) { text_found=true; if(empty_line && text_found && iter.starts_line()) break; + if(iter.is_start()) { + move_to_start=true; + break; + } iter.backward_char(); } - if(empty_line) { + if(empty_line && !move_to_start) { iter=get_iter_at_line_end(iter.get_line()); iter.forward_char(); if(!iter.starts_line()) // For CR+LF