From 6c2b9033cfb1a82275871b2800c5ef1e4cf877a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Wed, 13 Apr 2016 17:17:14 +0200 Subject: Use view_cursors_new_force where appropriate Close #263 --- sam.c | 16 ++-------------- vis-operators.c | 2 +- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/sam.c b/sam.c index 1b66df3..be0b14a 100644 --- a/sam.c +++ b/sam.c @@ -826,16 +826,8 @@ static bool cmd_guard(Vis *vis, Win *win, Command *cmd, const char *argv[], Curs static bool cmd_extract(Vis *vis, Win *win, Command *cmd, const char *argv[], Cursor *cur, Filerange *range) { bool ret = true; - View *view = win->view; Text *txt = win->file->text; - Cursor *cursor = NULL; - size_t pos = view_cursor_get(view); - if (cur && !view_cursors_dispose(cur)) { - cursor = view_cursors_new(view, text_size(txt)+1); - view_cursors_dispose(cur); - } - if (cmd->regex) { size_t start = range->start, end = range->end, last_start = EPOS; RegexMatch match[1]; @@ -901,11 +893,7 @@ static bool cmd_extract(Vis *vis, Win *win, Command *cmd, const char *argv[], Cu } } - if (cursor && !view_cursors_dispose(cursor)) { - view_cursors_selection_clear(cursor); - view_cursors_to(cursor, pos); - } - + view_cursors_dispose(cur); return ret; } @@ -972,7 +960,7 @@ static bool cmd_print(Vis *vis, Win *win, Command *cmd, const char *argv[], Curs if (cur) view_cursors_to(cur, pos); else - cur = view_cursors_new(view, pos); + cur = view_cursors_new_force(view, pos); if (cur) { if (range->start != range->end) view_cursors_selection_set(cur, range); diff --git a/vis-operators.c b/vis-operators.c index 5fb33b1..aceb3d1 100644 --- a/vis-operators.c +++ b/vis-operators.c @@ -176,7 +176,7 @@ static size_t op_cursor(Vis *vis, Text *txt, OperatorContext *c) { pos = text_line_finish(txt, line); else pos = text_line_start(txt, line); - view_cursors_new(view, pos); + view_cursors_new_force(view, pos); } return EPOS; } -- cgit v1.2.3