diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2017-07-09 12:23:57 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2017-07-10 18:26:05 +0200 |
| commit | 06db83de37afbaf347b317cc1870e99b43ac3460 (patch) | |
| tree | d92e927edaa69e3204459e41e9fcbaf0e7737b04 /main.c | |
| parent | 9da7d4b21bde029d028fd1fbeb46eb659fa7dc1c (diff) | |
| download | vis-06db83de37afbaf347b317cc1870e99b43ac3460.tar.gz vis-06db83de37afbaf347b317cc1870e99b43ac3460.tar.xz | |
vis: simplify selection complement and minus implementation
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -1759,7 +1759,7 @@ static const char *selections_intersect(Vis *vis, const char *keys, const Arg *a } static void complement(Array *ret, Array *a, Filerange *universe) { - size_t pos = 0; + size_t pos = universe->start; for (size_t i = 0, len = array_length(a); i < len; i++) { Filerange *r = array_get(a, i); if (pos < r->start) { @@ -1792,6 +1792,7 @@ static const char *selections_complement(Vis *vis, const char *keys, const Arg * } static const char *selections_minus(Vis *vis, const char *keys, const Arg *arg) { + Text *txt = vis_text(vis); View *view = vis_view(vis); bool anchored = view_selections_anchored(view_selections_primary_get(view)); enum VisMark mark = vis_mark_used(vis); @@ -1802,10 +1803,7 @@ static const char *selections_minus(Vis *vis, const char *keys, const Arg *arg) Array b_complement; array_init_from(&b_complement, &b); - Filerange universe = text_range_new(0, 0); - Filerange *max = array_get(&a, array_length(&a)-1); - if (max) - universe = text_range_new(max->end, max->end); + Filerange universe = text_object_entire(txt, 0); complement(&b_complement, &b, &universe); intersect(&sel, &a, &b_complement); |
