Skip to content

Commit

Permalink
Fix error with wrong terminal size during tab switch
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaraslaut committed Dec 28, 2024
1 parent a6b9d40 commit 265965d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
<description>
<ul>
<li>Do not abort when failing to create `XDG_STATE_HOME/contour/crash` directory</li>
<li>Fixes tab switch crash after resize</li>
</ul>
</description>
</release>
Expand Down
14 changes: 10 additions & 4 deletions src/contour/TerminalSessionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,27 @@ void TerminalSessionManager::setSession(size_t index)
if (!isAllowedToChangeTabs())
return;

Require(display != nullptr);
auto const pixels = display->pixelSize();
auto const totalPageSize = display->calculatePageSize() + vtbackend::LineCount { 1 };

auto* oldSession = _activeSession;

if (index < _sessions.size())
{
_activeSession = _sessions[index];
// Ensure that the existing session is resized to the display's size.
_activeSession->terminal().resizeScreen(totalPageSize, pixels);
}
else
createSession();

if (oldSession == _activeSession)
return;

Require(display != nullptr);
auto const pixels = display->pixelSize();
auto const totalPageSize = display->calculatePageSize() + _activeSession->terminal().statusLineHeight();

display->setSession(_activeSession);
// Resize active session after display is attached to it
// to return a lost line
_activeSession->terminal().resizeScreen(totalPageSize, pixels);
updateStatusLine();

Expand Down

0 comments on commit 265965d

Please sign in to comment.