]> git.lyx.org Git - features.git/commitdiff
TextMetrics::leftMargin(): Explain why the disabled code is wrong
authorVincent van Ravesteijn <vfr@lyx.org>
Thu, 10 May 2012 08:39:38 +0000 (10:39 +0200)
committerVincent van Ravesteijn <vfr@lyx.org>
Thu, 10 May 2012 08:46:35 +0000 (10:46 +0200)
src/TextMetrics.cpp

index 96da42d79fbd50698588cf7667a6af9487096ea1..1000affa05421b30e201e9a6de69e8690ab0d2d5 100644 (file)
@@ -1980,16 +1980,18 @@ int TextMetrics::leftMargin(int max_width,
 
        case MARGIN_RIGHT_ADDRESS_BOX: {
 #if 0
-               // ok, a terrible hack. The left margin depends on the widest
-               // row in this paragraph.
-               RowList::iterator rit = par.rows().begin();
-               RowList::iterator end = par.rows().end();
-               // FIXME: This is wrong.
+               // The left margin depends on the widest row in this paragraph.
+               // This code is wrong because it depends on the rows, but at the
+               // same time this function is used in redoParagraph to construct
+               // the rows. 
+               ParagraphMetrics const & pm = par_metrics_[pit];
+               RowList::const_iterator rit = pm.rows().begin();
+               RowList::const_iterator end = pm.rows().end();
                int minfill = max_width;
                for ( ; rit != end; ++rit)
                        if (rit->fill() < minfill)
                                minfill = rit->fill();
-               l_margin += theFontMetrics(params.getFont()).signedWidth(layout.leftmargin);
+               l_margin += theFontMetrics(buffer.params().getFont()).signedWidth(layout.leftmargin);
                l_margin += minfill;
 #endif
                // also wrong, but much shorter.