vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit c0518fb01aff19b0bb78e999f8ade631c8d04858
parent 1eb3f3108777588725548864ea5c42cad63cfabe
Author: Michal Bohuslávek <mbohuslavek@gmail.com>
Date:   Sun,  4 Jan 2015 11:10:33 +0100

Fix openline command on the first line

When on the first line, openline command wouldn't move the cursor to the
newly created line above the current line.

Diffstat:
Mvis.c | 11++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/vis.c b/vis.c @@ -1127,9 +1127,14 @@ static void put(const Arg *arg) { } static void openline(const Arg *arg) { - movement(&(const Arg){ .i = arg->i == MOVE_LINE_NEXT ? - MOVE_LINE_END : MOVE_LINE_PREV }); - insert_newline(NULL); + if (arg->i == MOVE_LINE_NEXT) { + movement(&(const Arg){ .i = MOVE_LINE_END }); + insert_newline(NULL); + } else { + movement(&(const Arg){ .i = MOVE_LINE_BEGIN }); + insert_newline(NULL); + movement(&(const Arg){ .i = MOVE_LINE_PREV }); + } switchmode(&(const Arg){ .i = VIS_MODE_INSERT }); }