]> git.lyx.org Git - features.git/commitdiff
Allow breaking a row element at a leading space
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 18 Jan 2016 14:32:07 +0000 (15:32 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 19 Jan 2016 08:55:31 +0000 (09:55 +0100)
When an inset is separated from the next strng by a space, it is reasonable to be able to break the string after its leading space.

Fixes bug #9921

src/Row.cpp

index bd0945961f415eb44e8768534652dee672038ee2..2bfe55a1b80d46d00b1aad0fbd6253d9910a4e74 100644 (file)
@@ -128,6 +128,18 @@ bool Row::Element::breakAt(int w, bool force)
                //lyxerr << "breakAt(" << w << ")  Row element Broken at " << x << "(w(str)=" << fm.width(str) << "): e=" << *this << endl;
                return true;
        }
+
+       // Qt will not break at a leading space, and we need that sometimes, see
+       //   http://www.lyx.org/trac/ticket/9921.
+       // It would be nice to fix this properly, but for now do it by hand.
+       // FIXME: figure out what to do for RtL text.
+       if (!isRTL() && !str.empty() && str[0] == ' ') {
+               dim.wid = 0;
+               str = ' ';
+               endpos = pos + 1;
+               return true;
+       }
+
        return false;
 }
 
@@ -466,7 +478,7 @@ void Row::shortenIfNeeded(pos_type const keep, int const w)
                        /* after breakAt, there may be spaces at the end of the
                         * string, but they are not counted in the string length
                         * (QTextLayout feature, actually). We remove them, but do
-                        * not change the endo of the row, since the spaces at row
+                        * not change the end of the row, since spaces at row
                         * break are invisible.
                         */
                        brk.str = rtrim(brk.str);