summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc.c7
-rw-r--r--nav.c2
2 files changed, 4 insertions, 5 deletions
diff --git a/doc.c b/doc.c
index 658315c..d5da6bf 100644
--- a/doc.c
+++ b/doc.c
@@ -23,15 +23,14 @@ void doc_fini(struct doc *d) {
}
void doc_new_line(struct doc *d) {
- size_t here = d->latest, there = d->txt.sz;
buf_grow(&d->txt, sizeof(struct doc_line));
- *(struct doc_line *)&d->txt.buf[there] = (struct doc_line) {
- .prev = there - here,
+ *(struct doc_line *)&d->txt.buf[d->txt.sz] = (struct doc_line) {
+ .prev = ((struct doc_line *)&d->txt.buf[d->latest])->len,
.link = DOC_LINK_NONE,
.len = 0
};
+ d->latest = d->txt.sz;
d->txt.sz += sizeof(struct doc_line);
- d->latest = there;
}
void doc_add_line(struct doc *d, const char *s) {
diff --git a/nav.c b/nav.c
index 8f1d699..8df829e 100644
--- a/nav.c
+++ b/nav.c
@@ -56,7 +56,7 @@ struct doc_line *nav_cur_line(struct nav_state *ns) {
int nav_line_up(struct nav_state *ns) {
if (ns->cur_ofs[ns->cur_doc] > 0) {
- ns->cur_ofs[ns->cur_doc] -= nav_cur_line(ns)->prev;
+ ns->cur_ofs[ns->cur_doc] -= nav_cur_line(ns)->prev + sizeof(struct doc_line);
return 1;
} else {
return 0;