aboutsummaryrefslogtreecommitdiff
path: root/sam.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2017-06-13 15:26:13 +0200
committerMarc André Tanner <mat@brain-dump.org>2017-06-15 15:51:43 +0200
commit60e6cf29521f3fa4bbb41b96e68b54f9502d7b96 (patch)
tree41e82eb2c95ecfd5a1798f4a0c021814aa546362 /sam.c
parentfdc73f01e040047a74d7323ca777055e061ec343 (diff)
downloadvis-60e6cf29521f3fa4bbb41b96e68b54f9502d7b96.tar.gz
vis-60e6cf29521f3fa4bbb41b96e68b54f9502d7b96.tar.xz
sam: simplify print command implementation
Diffstat (limited to 'sam.c')
-rw-r--r--sam.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/sam.c b/sam.c
index 6d6da1c..82463eb 100644
--- a/sam.c
+++ b/sam.c
@@ -1494,23 +1494,18 @@ static bool cmd_print(Vis *vis, Win *win, Command *cmd, const char *argv[], Sele
if (!win || !text_range_valid(range))
return false;
View *view = win->view;
- Text *txt = win->file->text;
- size_t pos = range->end;
- if (range->start != range->end)
- pos = text_char_prev(txt, pos);
- if (sel)
- view_cursors_to(sel, pos);
- else
- sel = view_selections_new_force(view, pos);
- if (sel) {
- if (range->start != range->end) {
- view_selections_set(sel, range);
- view_selections_anchor(sel);
- } else {
- view_selection_clear(sel);
- }
+ if (!sel)
+ sel = view_selections_new_force(view, range->start);
+ if (!sel)
+ return false;
+ if (range->start != range->end) {
+ view_selections_set(sel, range);
+ view_selections_anchor(sel);
+ } else {
+ view_cursors_to(sel, range->start);
+ view_selection_clear(sel);
}
- return sel != NULL;
+ return true;
}
static bool cmd_files(Vis *vis, Win *win, Command *cmd, const char *argv[], Selection *sel, Filerange *range) {