]> git.neil.brown.name Git - edlib.git/commitdiff
Change doc:replace to return result directly.
authorNeilBrown <neil@brown.name>
Tue, 8 Dec 2015 00:41:56 +0000 (11:41 +1100)
committerNeilBrown <neil@brown.name>
Wed, 9 Dec 2015 23:00:50 +0000 (10:00 +1100)
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 <neil@brown.name>
core.h
doc-text.c

diff --git a/core.h b/core.h
index 53f0a1dcb93718a20b6b14ec3e4b77dbfb38ecb3..3374748d6ff0f908f806f553bf2659874d6560de 100644 (file)
--- 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)
 {
index f3f6e1fa13cec167e20c5c41f8136407a49008d8..254c4ff024b0b49bb2a6afca3b4ce880e9e91678 100644 (file)
@@ -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;
 }