commit f7ca86d4c2b5bbbad94d6ab8db7c46c31f4603ca
parent 2c069027dcb6bd3bfba8201f871aa990b48da888
Author: Andreas Gruhler <agruhl@gmx.ch>
Date: Sun, 4 Jul 2021 18:25:16 +0200
fix n/N not moving to next
The n/N keys did not move to the next/previous entry. Probably a bug
introduced in 2cbfd5. The fix is not perfect, since g/G will not always
predictably return the very first/last entries. Instead it sometimes
returns the second first entry.
Diffstat:
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
@@ -37,8 +37,8 @@ This is a text based diary, inspired by [khal](https://github.com/pimutils/khal)
N go to the previous diary entry
n go to the next diary entry
- g go to the first journal entry
- G go to the last journal entry
+ g go to start of journal
+ G go to end of journal
J Go forward by 1 month
K Go backward by 1 month
diff --git a/diary.1 b/diary.1
@@ -63,8 +63,8 @@ q | quit the program
N | go to the previous journal entry
n | go to the next journal entry
-g | go to the first journal entry
-G | go to the last journal entry
+g | go to start of journal
+G | go to end of journal
t | jump to today
s | jump to specific day
diff --git a/diary.c b/diary.c
@@ -261,15 +261,15 @@ struct tm find_closest_entry(const struct tm current,
int step = search_backwards ? -1 : +1;
struct tm it = current;
+ it.tm_mday += step;
time_t it_time = mktime(&it);
for( ; it_time >= start_time && it_time <= end_time; it_time = mktime(&it)) {
- it.tm_mday += step;
if (date_has_entry(diary_dir, diary_dir_size, &it)) {
return it;
}
-
+ it.tm_mday += step;
}
return current;