From: NeilBrown Date: Tue, 8 Dec 2015 00:41:56 +0000 (+1100) Subject: Change doc:replace to return result directly. X-Git-Tag: lca2016~111 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=83bc10a13f8622d0867363754f9a177953d11fcb;p=edlib.git Change doc:replace to return result directly. There isn't must result here - just a flag to say "yes, a change was made". But it was being handled completely wrongly! I think it is fixed now. Signed-off-by: NeilBrown --- diff --git a/core.h b/core.h index 53f0a1dc..3374748d 100644 --- a/core.h +++ b/core.h @@ -356,14 +356,17 @@ static inline void doc_replace(struct pane *p, struct mark *m, char *str, bool *first) { struct cmd_info ci = {0}; + int ret; + ci.key = "doc:replace"; ci.focus = p; ci.mark = m; ci.str = str; ci.extra = *first; ci.numeric = 1; - key_handle_focus(&ci); - *first = ci.extra; + ret = key_handle_focus(&ci); + if (ret == 1) + *first = 1; } static inline int doc_undo(struct pane *p, bool redo) { diff --git a/doc-text.c b/doc-text.c index f3f6e1fa..254c4ff0 100644 --- a/doc-text.c +++ b/doc-text.c @@ -1379,7 +1379,7 @@ DEF_CMD(text_replace) struct mark *pm = dd->point; struct mark *end = ci->mark; char *str = ci->str; - bool first = ci->numeric; + bool first = ci->extra; struct mark *early = NULL; /* First delete, then insert */ @@ -1427,8 +1427,7 @@ DEF_CMD(text_replace) } point_notify_change(&t->doc, pm, early); - ci->numeric = first; - return 1; + return first ? 1 : 2; }