]> git.lyx.org Git - features.git/commitdiff
Automatically adjust tab stop width
authorDaniel Ramoeller <d.lyx@web.de>
Tue, 11 Apr 2023 11:21:23 +0000 (13:21 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 11 Apr 2023 11:36:52 +0000 (13:36 +0200)
Extend tab stops to the same indentation point instead of a fixed number of spaces.

Fix for bug #12736

src/TextMetrics.cpp

index f4241181c295e15f440d78a48f05dbf6d7621d5f..068eb31200bffad78a07b0bf5e7b86b874f04da4 100644 (file)
@@ -899,10 +899,13 @@ Row TextMetrics::tokenizeParagraph(pit_type const pit) const
                        FontMetrics const & fm = theFontMetrics(text_->labelFont(par));
                        int const wid = fm.width(par.layout().labelsep);
                        row.addMarginSpace(i, wid, *fi, par.lookupChange(i));
-               } else if (c == '\t')
-                       row.addSpace(i, theFontMetrics(*fi).width(from_ascii("    ")),
+               } else if (c == '\t') {
+                       // Make tab stop size adjust automatically depending on char number
+                       int tabStopWidth = 4;
+                       std::string s = std::string(tabStopWidth - i % tabStopWidth, ' ');
+                       row.addSpace(i, theFontMetrics(*fi).width(from_ascii(s)),
                                     *fi, par.lookupChange(i));
-               else if (c == 0x2028 || c == 0x2029) {
+               else if (c == 0x2028 || c == 0x2029) {
                        /**
                         * U+2028 LINE SEPARATOR
                         * U+2029 PARAGRAPH SEPARATOR