aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c10
-rw-r--r--text.c14
-rw-r--r--text.h4
-rw-r--r--vis-cmds.c11
4 files changed, 21 insertions, 18 deletions
diff --git a/main.c b/main.c
index 63d796b..5c9cc9f 100644
--- a/main.c
+++ b/main.c
@@ -1749,7 +1749,10 @@ static const char *redo(Vis *vis, const char *keys, const Arg *arg) {
}
static const char *earlier(Vis *vis, const char *keys, const Arg *arg) {
- size_t pos = text_earlier(vis_text(vis), vis_count_get_default(vis, 1));
+ size_t pos = EPOS;
+ VisCountIterator it = vis_count_iterator_get(vis, 1);
+ while (vis_count_iterator_next(&it))
+ pos = text_earlier(vis_text(vis));
if (pos != EPOS) {
view_cursor_to(vis_view(vis), pos);
/* redraw all windows in case some display the same file */
@@ -1759,7 +1762,10 @@ static const char *earlier(Vis *vis, const char *keys, const Arg *arg) {
}
static const char *later(Vis *vis, const char *keys, const Arg *arg) {
- size_t pos = text_later(vis_text(vis), vis_count_get_default(vis, 1));
+ size_t pos = EPOS;
+ VisCountIterator it = vis_count_iterator_get(vis, 1);
+ while (vis_count_iterator_next(&it))
+ pos = text_later(vis_text(vis));
if (pos != EPOS) {
view_cursor_to(vis_view(vis), pos);
/* redraw all windows in case some display the same file */
diff --git a/text.c b/text.c
index 291cc3a..7fdd237 100644
--- a/text.c
+++ b/text.c
@@ -763,18 +763,12 @@ static size_t history_traverse_to(Text *txt, Revision *rev) {
return pos;
}
-size_t text_earlier(Text *txt, int count) {
- Revision *rev = txt->history;
- while (count-- > 0 && rev->earlier)
- rev = rev->earlier;
- return history_traverse_to(txt, rev);
+size_t text_earlier(Text *txt) {
+ return history_traverse_to(txt, txt->history->earlier);
}
-size_t text_later(Text *txt, int count) {
- Revision *rev = txt->history;
- while (count-- > 0 && rev->later)
- rev = rev->later;
- return history_traverse_to(txt, rev);
+size_t text_later(Text *txt) {
+ return history_traverse_to(txt, txt->history->later);
}
size_t text_restore(Text *txt, time_t time) {
diff --git a/text.h b/text.h
index 607f239..3080acb 100644
--- a/text.h
+++ b/text.h
@@ -139,8 +139,8 @@ size_t text_undo(Text*);
* newest state i.e. there was nothing to redo.
*/
size_t text_redo(Text*);
-size_t text_earlier(Text*, int count);
-size_t text_later(Text*, int count);
+size_t text_earlier(Text*);
+size_t text_later(Text*);
/**
* Restore the text to the state closest to the time given
*/
diff --git a/vis-cmds.c b/vis-cmds.c
index 551c912..093c694 100644
--- a/vis-cmds.c
+++ b/vis-cmds.c
@@ -579,10 +579,13 @@ static bool cmd_earlier_later(Vis *vis, Win *win, Command *cmd, const char *argv
}
if (!*unit) {
- if (argv[0][0] == 'e')
- pos = text_earlier(txt, count);
- else
- pos = text_later(txt, count);
+ VisCountIterator it = vis_count_iterator_init(vis, count);
+ while (vis_count_iterator_next(&it)) {
+ if (argv[0][0] == 'e')
+ pos = text_earlier(txt);
+ else
+ pos = text_later(txt);
+ }
}
time_t state = text_state(txt);