vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit fee0d55424bbc871f6561fe23f083f9561b2a185 parent 051bd8d56e3e9ee1a67613bd3a9760e55bf9470b Author: Marc André Tanner <mat@brain-dump.org> Date: Fri, 24 Jul 2015 23:40:31 +0200 text: handle marks set to 0 and text_size(...) Diffstat:
| M | text.c | | | 8 | ++++++++ |
1 file changed, 8 insertions(+), 0 deletions(-)
diff --git a/text.c b/text.c @@ -1434,6 +1434,10 @@ size_t text_lineno_by_pos(Text *txt, size_t pos) { } Mark text_mark_set(Text *txt, size_t pos) { + if (pos == 0) + return (Mark)&txt->begin; + if (pos == txt->size) + return (Mark)&txt->end; Location loc = piece_get_extern(txt, pos); if (!loc.piece) return NULL; @@ -1445,6 +1449,10 @@ size_t text_mark_get(Text *txt, Mark mark) { if (!mark) return EPOS; + if (mark == (Mark)&txt->begin) + return 0; + if (mark == (Mark)&txt->end) + return txt->size; for (Piece *p = txt->begin.next; p->next; p = p->next) { if (p->data <= mark && mark < p->data + p->len)