From: NeilBrown Date: Sat, 9 Sep 2023 02:17:28 +0000 (+1000) Subject: Disable LOG during refresh if log is visible. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=9290bebb0e462b00f649a7fb1c1bc0bf1881be2c;p=edlib.git Disable LOG during refresh if log is visible. If there is a view on the log, then allowing log during refresh trigger recursion in unhelpful way. Also line-count is sync in testing mode, and log is big so disable line-count then. This allows log to be viewed when viewing a test. Signed-off-by: NeilBrown --- diff --git a/DOC/TODO.md b/DOC/TODO.md index 64b42b99..23c87435 100644 --- a/DOC/TODO.md +++ b/DOC/TODO.md @@ -89,7 +89,7 @@ Core features implemented at least by lib-search, doc-text and probably many others. It is particularly for things that are awkward to test with the ncurses/replay test approach. -- [ ] Send global notify before/after refresh. LOG must suspend logging +- [X] Send global notify before/after refresh. LOG must suspend logging (or notifications at least) during refresh if is visible anywhere - [ ] Do I want "Display" as in "Display:close", or "window" as in "window:notify". Decide, and make everything consistent. diff --git a/core-log.c b/core-log.c index 2c3ba63e..0c81c35f 100644 --- a/core-log.c +++ b/core-log.c @@ -37,7 +37,8 @@ struct logbuf { static struct log { struct doc doc; struct list_head log; - int blocked; + int blocked; + int refresh_active; } *log_doc safe; #include "core-pane.h" @@ -75,11 +76,16 @@ void LOG(char *fmt, ...) struct logbuf *b; struct timeval now; - if (!(void*)log_doc) + if (!(void*)log_doc || !log_pane) /* too early */ return; if (!fmt) return; + if (log_doc->refresh_active) { + /* Mustn't log anything if doc is being viewed */ + if (pane_notify("doc:notify-viewers", log_pane)) + return; + } if (log_doc->blocked) return; log_doc->blocked = 1; @@ -401,6 +407,14 @@ DEF_CMD(log_close) return 1; } +DEF_CMD(log_refresh_active) +{ + struct log *l = ci->home->doc_data; + + l->refresh_active = ci->num; + return 1; +} + static struct map *log_map; DEF_LOOKUP_CMD(log_handle, log_map); @@ -433,9 +447,16 @@ static void log_init(struct pane *ed safe) log_pane = doc_register(ed, &log_handle.c); if (!log_pane) return; + if (edlib_testing(ed)) + /* line-count is SYNC when testing, and log can + * get big - so disable + */ + attr_set_str(&log_pane->attrs, "linecount-disable", "yes"); log_doc = log_pane->doc_data; INIT_LIST_HEAD(&log_doc->log); + call("editor:request:Refresh-active", log_pane); + fname = getenv("EDLIB_LOG"); if (!fname || !*fname) return; @@ -461,6 +482,7 @@ void log_setup(struct pane *ed safe) key_add(log_map, "doc:destroy", &log_destroy); key_add(log_map, "doc:log:append", &log_append); key_add(log_map, "Close", &log_close); + key_add(log_map, "Refresh-active", &log_refresh_active); if(0)key_add(log_map, "debug:validate-marks", &log_val_marks); log_init(ed); diff --git a/core-pane.c b/core-pane.c index 1ba2bf14..28bc14aa 100644 --- a/core-pane.c +++ b/core-pane.c @@ -410,7 +410,7 @@ REDEF_CMD(pane_refresh) if (p->damaged & DAMAGED_CLOSED) return 1; - + call("editor:notify:Refresh-active", p, 1); time_start(TIME_REFRESH); while (cnt-- && (p->damaged & @@ -422,20 +422,24 @@ REDEF_CMD(pane_refresh) pane_do_refresh(p); p->damaged &= ~DAMAGED_DEBUG; } + if (cnt < 0) + p->damaged |= DAMAGED_DEBUG; pane_do_postorder(p); + p->damaged &= ~DAMAGED_DEBUG; if (p->damaged) { static time_t last_warn; static int rpt; if (last_warn + 5 < time(NULL)) rpt = 0; if (rpt++ < 5) - LOG("WARNING %sroot pane damaged after refresh: %d", + LOG("WARNING %sroot pane damaged after refresh: 0x%x", p->parent != p ? "":"non-", p->damaged); last_warn = time(NULL); call("editor:notify:Message:broadcast",p, 0, NULL, "Refresh looping - see log"); } time_stop(TIME_REFRESH); + call("editor:notify:Refresh-active", p, 0); return 1; } diff --git a/lib-linecount.c b/lib-linecount.c index ea22953a..ba233228 100644 --- a/lib-linecount.c +++ b/lib-linecount.c @@ -351,8 +351,6 @@ DEF_CMD(linecount_notify_count) /* num==1 means we don't want to wait for precision */ bool sync = ci->mark2 && ci->num != 1; - if (strcmp(ci->key, "CountLinesAsync") == 0) - sync = False; count_calculate(d, ci->mark2, ci->home, cli->view_num, sync); return 1;