<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div name="messageBodySection">
<div><span style="font-family:'Trebuchet MS', Helvetica, sans-serif;font-size:16px;"><Grrr. Forgot to attach the sample code ...></span></div>
</div>
<div name="messageReplySection">
<div>On Jun 1, 2026, 10:33 PM -0500, <a href="mailto:john@sturtz.org">john@sturtz.org</a>, wrote:<br />
</div>
<blockquote style="margin: 5px 5px; padding-left: 10px; border-left-width: thin; border-left-style: solid; border-left-color: #1abc9c;">
<div>
<div><span style="font-family:'Trebuchet MS', Helvetica, sans-serif;font-size:16px;">Hi again all.</span></div>
<div> </div>
<div><span style="font-family:'Trebuchet MS', Helvetica, sans-serif;font-size:16px;">I have a</span> <span style="font-family:'Courier New', Courier, monospace;font-size:16px;">QPlainTextEdit</span> <span style="font-family:'Trebuchet MS', Helvetica, sans-serif;font-size:16px;">widget. I place the cursor in the middle of a line, type a few characters and then hit [Enter]. Now if I want to undo that edit, it takes two</span> <span style="font-family:'Courier New', Courier, monospace;font-size:16px;">.undo()</span> <span style="font-family:'Trebuchet MS', Helvetica, sans-serif;font-size:16px;">calls -- the first removes the newline, the second the typed text.</span></div>
<div> </div>
<div><span style="font-family:'Trebuchet MS', Helvetica, sans-serif;font-size:16px;">I'd like to consider the entire edit one group, which a single</span> <span style="font-family:'Courier New', Courier, monospace;font-size:16px;">.undo()</span> <span style="font-family:'Trebuchet MS', Helvetica, sans-serif;font-size:16px;">undoes.</span></div>
<div> </div>
<div><span style="font-family:'Trebuchet MS', Helvetica, sans-serif;font-size:16px;">My ostensible solution was to call</span> <span style="font-family:'Courier New', Courier, monospace;font-size:16px;">.beginEditBlock()</span> <span style="font-family:'Trebuchet MS', Helvetica, sans-serif;font-size:16px;">prior to the edit, then</span> <span style="font-family:'Courier New', Courier, monospace;font-size:16px;">.endEditBlock()</span> <span style="font-family:'Trebuchet MS', Helvetica, sans-serif;font-size:16px;">after the edit. And that does in fact work -- a single</span> <span style="font-family:'Courier New', Courier, monospace;font-size:16px;">.undo()</span> <span style="font-family:'Trebuchet MS', Helvetica, sans-serif;font-size:16px;">call then undoes the entire edit. Unfortunately, after the</span> <span style="font-family:'Courier New', Courier, monospace;font-size:16px;">.beginEditBlock()</span> <span style="font-family:'Trebuchet MS', Helvetica, sans-serif;font-size:16px;">call, while the edit is occurring, the widget doesn't update.</span></div>
<div> </div>
<div><span style="font-family:'Trebuchet MS', Helvetica, sans-serif;font-size:16px;">------</span></div>
<div><span style="font-family:'Trebuchet MS', Helvetica, sans-serif;font-size:16px;">Sample code attached. To demonstrate:</span></div>
<div> </div>
<ol type="1">
<li><span style="font-family:'Trebuchet MS', Helvetica, sans-serif;font-size:16px;">Place cursor somewhere in the middle of the line. Type a few characters and hit [Enter].</span><br />
<span style="font-family:'Trebuchet MS', Helvetica, sans-serif;font-size:16px;">Type [ctrl+U] to manually call</span> <span style="font-family:'Courier New', Courier, monospace;font-size:16px;">.undo()</span><span style="font-family:'Trebuchet MS', Helvetica, sans-serif;font-size:16px;">. First time removes the newline, second time removes the typed characters.</span><br />
</li>
<li><span style="font-family:'Trebuchet MS', Helvetica, sans-serif;font-size:16px;">Place cursor somewhere (else) on the line.</span><br />
<span style="font-family:'Trebuchet MS', Helvetica, sans-serif;font-size:16px;">Type [alt+B] to call</span> <span style="font-family:'Courier New', Courier, monospace;font-size:16px;">.beginEditBlock()</span><span style="font-family:'Trebuchet MS', Helvetica, sans-serif;font-size:16px;">.</span><br />
<span style="font-family:'Trebuchet MS', Helvetica, sans-serif;font-size:16px;">Type a few characters and hit [Enter]. The characters overtype, and the widget doesn't update.</span><br />
<span style="font-family:'Trebuchet MS', Helvetica, sans-serif;font-size:16px;">Type [alt+E] to call</span> <span style="font-family:'Courier New', Courier, monospace;font-size:16px;">.endEditBlock()</span><span style="font-family:'Trebuchet MS', Helvetica, sans-serif;font-size:16px;">. Now the widget updates.</span><br />
<span style="font-family:'Trebuchet MS', Helvetica, sans-serif;font-size:16px;">A single [ctrl+U] undoes the entire edit.</span></li>
</ol>
<div> </div>
<div><span style="font-family:'Trebuchet MS', Helvetica, sans-serif;font-size:16px;">------</span></div>
<div><span style="font-family:'Trebuchet MS', Helvetica, sans-serif;font-size:16px;">Are</span> <span style="font-family:'Courier New', Courier, monospace;font-size:16px;">.beginEditBlock()/.endEditBlock()</span> <span style="font-family:'Trebuchet MS', Helvetica, sans-serif;font-size:16px;">only really intended to be used for programmatic editing of the text and not user interaction?</span></div>
<div> </div>
<div><span style="font-family:'Trebuchet MS', Helvetica, sans-serif;font-size:16px;">Thanks!</span></div>
<div> </div>
<div><span style="font-family:'Trebuchet MS', Helvetica, sans-serif;font-size:16px;">/John</span></div>
</div>
</blockquote>
</div>
</body>
</html>