Skip to content

Commit

Permalink
Preserve existent logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaraslaut committed Dec 31, 2024
1 parent ee40f19 commit 46cadcf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions src/contour/TerminalSessionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void TerminalSessionManager::setSession(size_t index)
activateSession(createSessionInBackground());
}

TerminalSession* TerminalSessionManager::activateSession(TerminalSession* session)
TerminalSession* TerminalSessionManager::activateSession(TerminalSession* session, bool isNewSession)
{
managerLog()(
"Activating session ID {} at index {}", session->id(), getSessionIndexOf(session).value_or(-1));
Expand All @@ -127,10 +127,11 @@ TerminalSession* TerminalSessionManager::activateSession(TerminalSession* sessio
managerLog()("Attaching display to session.");
auto const pixels = display->pixelSize();
auto const totalPageSize =
display->calculatePageSize() + _activeSession->terminal().statusLineHeight();
display->calculatePageSize() + _previousActiveSession->terminal().statusLineHeight();

// Ensure that the existing session is resized to the display's size.
_activeSession->terminal().resizeScreen(totalPageSize, pixels);
if(!isNewSession)
_activeSession->terminal().resizeScreen(totalPageSize, pixels);

display->setSession(_activeSession);

Expand All @@ -144,12 +145,12 @@ TerminalSession* TerminalSessionManager::activateSession(TerminalSession* sessio

void TerminalSessionManager::addSession()
{
activateSession(createSessionInBackground());
activateSession(createSessionInBackground(), true);
}

void TerminalSessionManager::switchToPreviousTab()
{
managerLog()("SWITCH TO LAST TAB (current: {}, last: {})",
managerLog()("switch to previous tab (current: {}, previous: {})",
getSessionIndexOf(_activeSession).value_or(-1),
getSessionIndexOf(_previousActiveSession).value_or(-1));

Expand All @@ -162,7 +163,7 @@ void TerminalSessionManager::switchToPreviousTab()
void TerminalSessionManager::switchToTabLeft()
{
const auto currentSessionIndex = getCurrentSessionIndex();
managerLog()(std::format("PREVIOUS TAB: currentSessionIndex: {}, _sessions.size(): {}",
managerLog()(std::format("previous tab: currentSessionIndex: {}, _sessions.size(): {}",
currentSessionIndex,
_sessions.size()));

Expand Down
2 changes: 1 addition & 1 deletion src/contour/TerminalSessionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TerminalSessionManager: public QAbstractListModel
TerminalSessionManager(ContourGuiApp& app);

contour::TerminalSession* createSessionInBackground();
contour::TerminalSession* activateSession(TerminalSession* session);
contour::TerminalSession* activateSession(TerminalSession* session, bool isNewSession = false);

Q_INVOKABLE contour::TerminalSession* createSession();
Q_INVOKABLE void addSession();
Expand Down

0 comments on commit 46cadcf

Please sign in to comment.