vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 366416ed9059e07a7841d917a140b83dd65fc745
parent d26ac2103119d7b809c15b980eb34f5974c5fac9
Author: Marc André Tanner <mat@brain-dump.org>
Date: Wed, 13 Apr 2016 17:37:29 +0200
vis: stop repeated motions as soon as resulting position remains the same
This improves responsiveness of {count}j for files with less than count
lines. For huge files this will still be slow because the code tries
to restore cursor position on every line before moving on to the next.
Also moving up will generally be slower than downwards. Use {count}%
(fastest) or or :count (slower) instead.
Close #267
Diffstat:
| M | vis.c | | | 3 | ++- |
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/vis.c b/vis.c @@ -495,6 +495,7 @@ void action_do(Vis *vis, Action *a) { if (a->movement) { size_t start = pos; for (int i = 0; i < count; i++) { + size_t pos_prev = pos; if (a->movement->txt) pos = a->movement->txt(txt, pos); else if (a->movement->cur) @@ -509,7 +510,7 @@ void action_do(Vis *vis, Action *a) { pos = a->movement->win(vis, win, pos); else if (a->movement->user) pos = a->movement->user(vis, win, a->movement->data, pos); - if (pos == EPOS || a->movement->type & IDEMPOTENT) + if (pos == EPOS || a->movement->type & IDEMPOTENT || pos == pos_prev) break; }