<p dir="auto">Windows 10 Home 1903</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Windows build number: 18362.356
Windows Terminal version: 0.5.2762.0"><pre lang="none" class="notranslate"><code class="notranslate">Windows build number: 18362.356
Windows Terminal version: 0.5.2762.0
</code></pre></div>
<ol dir="auto">
<li>Open Azure cloud shell</li>
<li>resize the window horizontally, using mouse</li>
</ol>

<p dir="auto">Text should wrap according to the width of the window</p>

<p dir="auto">Text disappears, which does not the window and disappears after reducing width and does not come back after increasing it.</p>
<p dir="auto">Apologies if this explanation is confusing. I've mentally internalized the problem here, but I'm not sure if I can fully articulate. Here goes...</p>
<p dir="auto">When receiving characters in a stream fashion (in either conhost or the Terminal), there are a bunch of situations that occur that run off the golden path rails of "just put this into the buffer and move the cursor forward by one".</p>
<p dir="auto">A few major categories of these are:</p>
<ol dir="auto">
<li>C0 control characters (tab, backspace, newline, carriage return, etc.)</li>
<li>Surrogate pairs for UTF-16 (two wchar_ts are required to form one U+ codepoint)</li>
<li>An entire run of characters required to figure out a particular cell display or run of cells.</li>
</ol>
<p dir="auto">We need to solve 1 and 2 first. Solving 3 will probably require a bit more interaction with the <code class="notranslate">CustomTextLayout</code> in the DirectWrite renderer to perform some sort of read-ahead or multiple-pass calculation over text as it flows in stream-wise to figure out the columns it should take.</p>
<p dir="auto">The existing manifests of this sort of work are <code class="notranslate">WriteCharsLegacy</code> in the console host (which is a thousand line or more monstrosity full of multi-pass switch cases, loops, and gotos) and the stream write thing in <code class="notranslate">TerminalControl</code> (I think, might be <code class="notranslate">TerminalConnection</code>) which <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/zadjii-msft/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/zadjii-msft">@zadjii-msft</a> affectionately warned against it becoming "WriteCharsLegacy2ElectricBoogaloo" in one of his comments.</p>
<p dir="auto">I think what needs to be done here is:</p>
<ol dir="auto">
<li>Create a third entry point to the buffer object that accepts text in a stream write fashion, potentially "buffering" before it inserts into the buffer for reals (or has the ability to look-behind at what was just written) taking over the duties of the "WriteCharsLegacy" type methods into the buffer itself so at least 1 and 2 can be handled in a unified-ish manner.</li>
<li>Teach the buffer and/or let the buffer accept some sort of loose pfn that will connect it up to the text layout engine and let it query for column counts or glyph run information as stream characters show up and adjust the behavior of their neighboring glyphs.</li>
</ol>