Attached is a patch that refreshes previews whenever the user activates or deactivates a branch. The motivation for this patch is that if a child document is previewed in the master document, and if the child document has the branch inside it as well, the preview will be incorrect when the branch is toggled (without this patch).
However, this patch will cause all previews to refresh. I'm concerned that the inefficiency is not worth the benefit. Any thoughts on this patch and any thoughts on an ideal solution? For example, would removePreviews() and updatePreviews() ideally have arguments that allow to specify which type of previews to update? Scott
From 970f2425842f3c4aeb699b71fe4c5bd883e440c5 Mon Sep 17 00:00:00 2001 From: Scott Kostyshak <skost...@lyx.org> Date: Sun, 8 Dec 2019 21:10:01 -0500 Subject: [PATCH] Refresh previews on branch toggle For example, if this branch is toggled in a master document and the branch also exists in a child document that is previewed in the master document, the preview will be incorrect if it is not updated. --- src/insets/InsetBranch.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/insets/InsetBranch.cpp b/src/insets/InsetBranch.cpp index 88d00e641e..423ce71f89 100644 --- a/src/insets/InsetBranch.cpp +++ b/src/insets/InsetBranch.cpp @@ -190,6 +190,17 @@ void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd) // cur.forceBufferUpdate() is not enough buf->updateBuffer(); } + // Refresh previews in case content in this branch causes a preview inset to + // change output. e.g., if this branch is toggled in a master document and the + // branch also exists in a child document that is previewed in the master + // document, the preview will be incorrect if it is not updated. + // TODO We might not need to refresh all previews. e.g., if some preview + // insets are self-contained (no activation can change their preview), + // there is no need to refresh them. Similarly, for child documents we only + // need to refresh the preview if the child document contains the particular + // branch being toggled. + buf->removePreviews(); + buf->updatePreviews(); break; } case LFUN_BRANCH_INVERT: -- 2.20.1
signature.asc
Description: PGP signature
-- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel