<table><tr><td style="">poboiko added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D29107">View Revision</a></tr></table><br /><div><div><blockquote style="border-left: 3px solid #8C98B8;
          color: #6B748C;
          font-style: italic;
          margin: 4px 0 12px 0;
          padding: 8px 12px;
          background-color: #F8F9FC;">
<div style="font-style: normal;
          padding-bottom: 4px;">In <a href="https://phabricator.kde.org/D29107#655102" style="background-color: #e7e7e7;
          border-color: #e7e7e7;
          border-radius: 3px;
          padding: 0 4px;
          font-weight: bold;
          color: black;text-decoration: none;">D29107#655102</a>, <a href="https://phabricator.kde.org/p/dfaure/" style="
              border-color: #f1f7ff;
              color: #19558d;
              background-color: #f1f7ff;
                border: 1px solid transparent;
                border-radius: 3px;
                font-weight: bold;
                padding: 0 4px;">@dfaure</a> wrote:</div>
<div style="margin: 0;
          padding: 0;
          border: 0;
          color: rgb(107, 116, 140);"><p>You say "The format does not seem to exist before the first character" and yet that's exactly where you're moving the cursor.<br />
 The code looks ok to me, but the comment is confusing/wrong.</p></div>
</blockquote>

<p>Fair point. I've just copied the comment from the old code, without much thinking about it.</p>

<blockquote style="border-left: 3px solid #a7b5bf; color: #464c5c; font-style: italic; margin: 4px 0 12px 0; padding: 4px 12px; background-color: #f8f9fc;"><p>It's just about setting the format of the cursor from the first char. I agree that it's probably a bug that setDocument doesn't trigger that, but I'm not sure the old bug report reference still makes sense here, it feels like a different issue to me (the comment and old workaround says "there's nothing at pos 0, go to pos 1 to grab the format"). Unrelated to your issue and fix.</p></blockquote>

<p>I think actually that the comment was about the same issue, but the author actually misinterpreted it. When we're going to pos 1 to grab the format, we are still grabbing it from the very first character and very first block in the document. The <tt style="background: #ebebeb; font-size: 13px;">moveCursor(Start)</tt> does it too.</p>

<hr class="remarkup-hr" />

<p>This is freshly opened document without the patch (note the font size is 10 and bold is not marked, although the first symbol is of size 20 and is bold):<br />
<a href="https://phabricator.kde.org/F8255333" style="background-color: #e7e7e7;
          border-color: #e7e7e7;
          border-radius: 3px;
          padding: 0 4px;
          font-weight: bold;
          color: black;text-decoration: none;">F8255333: scr1.png</a><br />
This is what happens if I more cursor to the right (the cursor is not visible, but it's at pos 1, at it grabbed style from the first symbol: it's bold and of size 20. I can now freely move it back to the left, and the style will be preserved. That's the old workaround):<br />
<a href="https://phabricator.kde.org/F8255335" style="background-color: #e7e7e7;
          border-color: #e7e7e7;
          border-radius: 3px;
          padding: 0 4px;
          font-weight: bold;
          color: black;text-decoration: none;">F8255335: scr2.png</a><br />
And that's the screenshot with this patch (which doesn't move it to the pos 1, but to the start; the cursor is adjusted from the very beginning):<br />
<a href="https://phabricator.kde.org/F8255338" style="background-color: #e7e7e7;
          border-color: #e7e7e7;
          border-radius: 3px;
          padding: 0 4px;
          font-weight: bold;
          color: black;text-decoration: none;">F8255338: scr3.png</a></p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R573 KJots</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D29107">https://phabricator.kde.org/D29107</a></div></div><br /><div><strong>To: </strong>poboiko, dvratil, dfaure<br /><strong>Cc: </strong>kde-pim, fbampaloukas, dcaliste, dvasin, rodsevich, winterz, vkrause, mlaurent, knauss, dvratil<br /></div>