commit dea5ba16de1b98d93cf30ab65119bc2364a7ac2b
Author: Enrico Forestieri <[email protected]>
Date:   Sun Oct 23 18:23:41 2016 +0200

    Correctly track ulem commands with change tracking
    
    LyX assumes that everything in \lyxdeleted is struck out by ulem
    and increases the corresponding counter. However, deleted display
    math material is struck out using tikz. As we also take into
    account the deletion of underlined display math (in order to
    properly position such material vertically), we have to take
    care that the count is correct.
---
 src/Changes.cpp      |    5 +++--
 src/OutputParams.cpp |    2 +-
 src/OutputParams.h   |    7 ++++++-
 src/Paragraph.cpp    |    1 +
 4 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/Changes.cpp b/src/Changes.cpp
index 6e10dd1..90ad075 100644
--- a/src/Changes.cpp
+++ b/src/Changes.cpp
@@ -428,7 +428,7 @@ int Changes::latexMarkChange(otexstream & os, BufferParams 
const & bparams,
                // close \lyxadded or \lyxdeleted
                os << '}';
                column++;
-               if (oldChange.type == Change::DELETED)
+               if (oldChange.type == Change::DELETED && 
!runparams.wasDisplayMath)
                        --runparams.inulemcmd;
        }
 
@@ -440,7 +440,8 @@ int Changes::latexMarkChange(otexstream & os, BufferParams 
const & bparams,
        docstring macro_beg;
        if (change.type == Change::DELETED) {
                macro_beg = from_ascii("\\lyxdeleted{");
-               ++runparams.inulemcmd;
+               if (!runparams.inDisplayMath)
+                       ++runparams.inulemcmd;
        }
        else if (change.type == Change::INSERTED)
                macro_beg = from_ascii("\\lyxadded{");
diff --git a/src/OutputParams.cpp b/src/OutputParams.cpp
index 1633cf3..2fdc065 100644
--- a/src/OutputParams.cpp
+++ b/src/OutputParams.cpp
@@ -23,7 +23,7 @@ OutputParams::OutputParams(Encoding const * enc)
          moving_arg(false), intitle(false), inulemcmd(0), local_font(0), 
master_language(0),
          encoding(enc), free_spacing(false), use_babel(false), 
use_polyglossia(false),
          use_indices(false), use_japanese(false), linelen(0), depth(0),
-         exportdata(new ExportData), inDisplayMath(false),
+         exportdata(new ExportData), inDisplayMath(false), 
wasDisplayMath(false),
          inComment(false), inTableCell(NO), inFloat(NONFLOAT),
          inIndexEntry(false), inIPA(false), inDeletedInset(0),
          changeOfDeletedInset(Change::UNCHANGED),
diff --git a/src/OutputParams.h b/src/OutputParams.h
index 3b97a3e..b3359d4 100644
--- a/src/OutputParams.h
+++ b/src/OutputParams.h
@@ -187,11 +187,16 @@ public:
        */
        std::shared_ptr<ExportData> exportdata;
 
-       /** Whether we are inside a display math inset.
+       /** Whether we are entering a display math inset.
         *  Needed to correctly strike out deleted math in change tracking.
         */
        mutable bool inDisplayMath;
 
+       /** Whether we are leaving a display math inset.
+        *  Needed to correctly track nested ulem commands in change tracking.
+        */
+       mutable bool wasDisplayMath;
+
        /** Whether we are inside a comment inset. Insets that are including
         *  external files like InsetGraphics, InsetInclude and InsetExternal
         *  may only write the usual output and must not attempt to do
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index aea3234..8afa475 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -2389,6 +2389,7 @@ void Paragraph::latex(BufferParams const & bparams,
                                                            runparams);
                }
 
+               runparams.wasDisplayMath = runparams.inDisplayMath;
                runparams.inDisplayMath = false;
                bool deleted_display_math = false;
 

Reply via email to