<h1 dir="auto">Environment</h1>
<p dir="auto">Windows build number: Version 10.0.18362.175<br>
Windows Terminal version (if applicable): Commit <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/microsoft/terminal/commit/a08666b58eb65b85ddf94e69892fa3e0a084ba98/hovercard" href="https://github.com/microsoft/terminal/commit/a08666b58eb65b85ddf94e69892fa3e0a084ba98"><tt>a08666b</tt></a></p>
<h1 dir="auto">Steps to reproduce</h1>
<ol dir="auto">
<li>Start the Windows Terminal (Dev Build).</li>
<li>Open an Ubuntu tab (or whatever Linux shell you have).</li>
<li>Do a bunch of directory listings that really fill up the scrollback buffer (the System32 directory is good for that).</li>
<li>Execute <code class="notranslate">printf "\e[3J"</code> to clear the scrollback buffer.</li>
</ol>
<h1 dir="auto">Expected behavior</h1>
<p dir="auto">The scrollback buffer should be cleared and control returned to the user almost immediately.</p>
<h1 dir="auto">Actual behavior</h1>
<p dir="auto">The app essentially stops responding. It will return to normal eventually, but how long that takes depends on the speed of your computer and how full the scrollback was to start with.</p>
<p dir="auto">This might be a duplicate of one of the other freeze-on-exit bugs (e.g. <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="459517763" data-permission-text="Title is private" data-url="https://github.com/microsoft/terminal/issues/1445" data-hovercard-type="issue" data-hovercard-url="/microsoft/terminal/issues/1445/hovercard" href="https://github.com/microsoft/terminal/issues/1445">#1445</a>), since the terminal seems to generate an erase scrollback call whenever you exit. But it only happens when actually typing <code class="notranslate">exit</code> in the shell - closing the tab directly works OK.</p>
<p dir="auto">From what I've been able to determine, the source of the problem is in the <code class="notranslate">Terminal::EraseInDisplay</code> method. When the eraseType is <code class="notranslate">EraseType::Scrollback</code>, it performs a loop to clear every line of the scrollback:</p>
<p dir="auto"></p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/microsoft/terminal/blob/a08666b58eb65b85ddf94e69892fa3e0a084ba98/src/cascadia/TerminalCore/TerminalApi.cpp#L340-L345">terminal/src/cascadia/TerminalCore/TerminalApi.cpp</a>
    </p>
    <p class="mb-0 color-fg-muted">
        Lines 340 to 345
      in
      <a data-pjax="true" class="commit-tease-sha" href="/microsoft/terminal/commit/a08666b58eb65b85ddf94e69892fa3e0a084ba98">a08666b</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L340" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="340"></td>
          <td id="LC340" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-k">auto</span> eraseIter = <span class="pl-c1">OutputCellIterator</span>(UNICODE_SPACE, _buffer-&gt;<span class="pl-c1">GetCurrentAttributes</span>(), _mutableViewport.<span class="pl-c1">RightInclusive</span>() * (eraseEnd - eraseStart + <span class="pl-c1">1</span>)); </td>
        </tr>

        <tr class="border-0">
          <td id="L341" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="341"></td>
          <td id="LC341" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-k">for</span> (SHORT i = eraseStart; i &lt;= eraseEnd; i++) </td>
        </tr>

        <tr class="border-0">
          <td id="L342" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="342"></td>
          <td id="LC342" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> { </td>
        </tr>

        <tr class="border-0">
          <td id="L343" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="343"></td>
          <td id="LC343" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     COORD erasePos{ <span class="pl-c1">0</span>, i }; </td>
        </tr>

        <tr class="border-0">
          <td id="L344" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="344"></td>
          <td id="LC344" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     _buffer-&gt;<span class="pl-c1">Write</span>(eraseIter, erasePos); </td>
        </tr>

        <tr class="border-0">
          <td id="L345" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="345"></td>
          <td id="LC345" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> } </td>
        </tr>
    </tbody></table>
  </div>
</div>
<p></p>
<p dir="auto">Note that the <em>eraseIter</em> <code class="notranslate">OutputCellIterator</code> is set to the size of the full area being cleared, but a <code class="notranslate">_buffer-&gt;Write</code> call is made with that iterator for every line. Each one of those calls is enough to clear the entire area, so it's essentially performing a huge write operation over and over again. If your scrollback buffer is large, this can take forever.</p>
<p dir="auto">I think this is probably a regression. I have preview build 0.2.1831.0 installed on this machine too, and that doesn't seem to have the problem.</p>
<h1 dir="auto">Environment</h1>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="18362.449: [run `[Environment]::OSVersion: 1903]
Windows Terminal version (if applicable):V0.6

Any other software?"><pre lang="none" class="notranslate"><code class="notranslate">18362.449: [run `[Environment]::OSVersion: 1903]
Windows Terminal version (if applicable):V0.6

Any other software?
</code></pre></div>
<h1 dir="auto">Steps to reproduce</h1>
<p dir="auto">my project just use euc-jp encode<br>
powerShell command:<br>
chcp 20932<br>
but can't read text for euc-jp encode<br>
and i can't change to write japanese</p>

<h1 dir="auto">Expected behavior</h1>

<h1 dir="auto">Actual behavior</h1>