Guys,
with Dov's latest patch (#1820) committed, I was able to produce a CT
patch that does not touch the present (non-)const-ness of OutputParams.
Since I consider this bug a major CT bug (text inside deleted insets is
displayed as unchanged text), I would like you to reconsider the patch
for 1.5.0.
In a certain sense, it is a one-liner because it effects current
behavior only with this statement:
- Change const & change = pimpl_->lookupChange(i);
+ Change const & change = runparams.inDeletedInset ?
runparams.changeOfDeletedInset
+ :
pimpl_->lookupChange(i);
Implementation notes:
In order to fix the bug, it is necessary to pass information down the
call stack. Prior to #1820, it would have been possible to make a local
copy of the (const) outputparams, modify them locally, and pass the
modified params down. However, it turns out that Dov needs to pass
information _up_. Therefore, IMHO it is not a good idea to create local
copies of outputParams in the same method. Instead, I modify the needed
parameter at the beginning and reset them at the end
(increment/decrement of inDeletedInset).
Kind regards,
Michael
Index: src/OutputParams.h
===================================================================
--- src/OutputParams.h (Revision 19151)
+++ src/OutputParams.h (Arbeitskopie)
@@ -16,6 +16,7 @@
#include "support/types.h"
#include <boost/shared_ptr.hpp>
+#include "Changes.h"
namespace lyx {
@@ -120,6 +121,16 @@
*/
bool inComment;
+ /** Whether we are inside an inset that is logically deleted.
+ * A value > 0 indicates a deleted inset.
+ */
+ int inDeletedInset;
+
+ /** The change information of the outermost, logically deleted inset.
+ * changeOfDeletedInset shall only be evaluated if inDeletedInset > 0.
+ */
+ Change changeOfDeletedInset;
+
/** allow output of only part of the top-level paragraphs
* par_begin: beginning paragraph
*/
Index: src/Paragraph.cpp
===================================================================
--- src/Paragraph.cpp (Revision 19151)
+++ src/Paragraph.cpp (Arbeitskopie)
@@ -726,6 +726,11 @@
break;
}
+ if (lookupChange(i).type == Change::DELETED) {
+ if( ++runparams.inDeletedInset == 1)
+ runparams.changeOfDeletedInset = lookupChange(i);
+ }
+
if (inset->canTrackChanges()) {
column += Changes::latexMarkChange(os, bparams, running_change,
Change(Change::UNCHANGED));
@@ -801,6 +806,10 @@
} else {
column += os.tellp() - len;
}
+
+ if (lookupChange(i).type == Change::DELETED) {
+ --runparams.inDeletedInset;
+ }
}
break;
@@ -2039,7 +2048,8 @@
runparams.moving_arg);
}
- Change const & change = pimpl_->lookupChange(i);
+ Change const & change = runparams.inDeletedInset ? runparams.changeOfDeletedInset
+ : pimpl_->lookupChange(i);
if (bparams.outputChanges && runningChange != change) {
if (open_font) {
Index: src/OutputParams.cpp
===================================================================
--- src/OutputParams.cpp (Revision 19151)
+++ src/OutputParams.cpp (Arbeitskopie)
@@ -22,7 +22,7 @@
local_font(0), encoding(enc), free_spacing(false), use_babel(false),
linelen(0), depth(0),
exportdata(new ExportData),
- inComment(false),
+ inComment(false), inDeletedInset(0), changeOfDeletedInset(Change::UNCHANGED),
par_begin(0), par_end(0),
dryrun(false)
{}