]> git.lyx.org Git - lyx.git/blobdiff - src/rowpainter.cpp
Fix layout bug. Pasting text into a cell tried to set Standard layout, because
[lyx.git] / src / rowpainter.cpp
index d53389fd11546d76bfa7928beead2fa3976a913c..6d56c27b60db69ccbb6743e91c3930cc8d68000e 100644 (file)
@@ -224,10 +224,6 @@ void RowPainter::paintChars(pos_type & vpos, FontInfo const & font,
 {
        // This method takes up 70% of time when typing
        pos_type pos = bidi_.vis2log(vpos);
-       pos_type const end = row_.endpos();
-       FontSpan const font_span = par_.fontSpan(pos);
-       Change::Type const prev_change = par_.lookupChange(pos).type;
-
        // first character
        vector<char_type> str;
        str.reserve(100);
@@ -242,6 +238,10 @@ void RowPainter::paintChars(pos_type & vpos, FontInfo const & font,
                str[0] = par_.transformChar(c, pos);
        }
 
+       pos_type const end = row_.endpos();
+       FontSpan const font_span = par_.fontSpan(pos);
+       // Track-change status.
+       Change::Type const change_type = par_.lookupChange(pos).type;
        // selected text?
        bool const selection = pos >= row_.sel_beg && pos < row_.sel_end;
 
@@ -252,10 +252,12 @@ void RowPainter::paintChars(pos_type & vpos, FontInfo const & font,
                        break;
 
                bool const new_selection = pos >= row_.sel_beg && pos < row_.sel_end;
-               if (selection != new_selection)
+               if (new_selection != selection)
+                       // Selection ends or starts here.
                        break;
 
-               if (prev_change != par_.lookupChange(pos).type)
+               if (change_type != par_.lookupChange(pos).type)
+                       // Track change type has changed.
                        break;
 
                char_type c = par_.getChar(pos);
@@ -304,18 +306,18 @@ void RowPainter::paintChars(pos_type & vpos, FontInfo const & font,
 
        docstring s(&str[0], str.size());
 
-       if (!selection && prev_change == Change::UNCHANGED) {
+       if (!selection && change_type == Change::UNCHANGED) {
                x_ += pi_.pain.text(int(x_), yo_, s, font);
                return;
        }
        
        FontInfo copy = font;
-       if (selection)
-               copy.setColor(Color_selectiontext);
-       else if (prev_change == Change::DELETED)
+       if (change_type == Change::DELETED)
                copy.setColor(Color_deletedtext);
-       else if (prev_change == Change::INSERTED)
+       else if (change_type == Change::INSERTED)
                copy.setColor(Color_addedtext);
+       else if (selection)
+               copy.setColor(Color_selectiontext);
 
        x_ += pi_.pain.text(int(x_), yo_, s, copy);
 }
@@ -836,8 +838,6 @@ void RowPainter::paintInlineCompletion(Font const & font)
        // right to left?
        if (rtl) {
                swap(s1, s2);
-               reverse(s1.begin(), s1.end());
-               reverse(s2.begin(), s2.end());
                swap(c1, c2);
        }