Skip to content

Commit

Permalink
[contour] Ensure inserting happens right next to the currently active…
Browse files Browse the repository at this point in the history
… tab

Signed-off-by: Christian Parpart <christian@parpart.family>
Rate limit · GitHub

Access has been restricted

You have triggered a rate limit.

Please wait a few minutes before you try again;
in some cases this may take up to an hour.

christianparpart committed Jan 1, 2025
1 parent a5f8dd3 commit 2a17dfa
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions metainfo.xml
Original file line number Diff line number Diff line change
@@ -108,6 +108,7 @@
<description>
<ul>
<li>Adds `MoveTabToLeft` and `MoveTabToRight` actions to move tabs around (#1695)</li>
<li>Ensure inserting new tabs happens right next to the currently active tab (#1695)</li>
</ul>
</description>
</release>
2 changes: 1 addition & 1 deletion src/contour/TerminalSession.cpp
Original file line number Diff line number Diff line change
@@ -1434,7 +1434,7 @@ bool TerminalSession::operator()(actions::WriteScreen const& event)

bool TerminalSession::operator()(actions::CreateNewTab)
{
emit createNewTab();
_manager->createSession();
return true;
}

6 changes: 5 additions & 1 deletion src/contour/TerminalSessionManager.cpp
Original file line number Diff line number Diff line change
@@ -79,7 +79,11 @@ TerminalSession* TerminalSessionManager::createSessionInBackground()
auto* session = new TerminalSession(this, createPty(ptyPath), _app);
managerLog()("Create new session with ID {} at index {}", session->id(), _sessions.size());

_sessions.push_back(session);
auto const currentSessionIterator = std::ranges::find(_sessions, _activeSession);
auto const insertPoint = currentSessionIterator != _sessions.end() ? std::next(currentSessionIterator)
: currentSessionIterator;

_sessions.insert(insertPoint, session);

connect(session, &TerminalSession::sessionClosed, [this, session]() { removeSession(*session); });

0 comments on commit 2a17dfa

Please sign in to comment.