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>
  • Loading branch information
christianparpart committed Jan 1, 2025
1 parent a5f8dd3 commit 9f3ec38
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@
<release version="0.6.2" urgency="medium" type="development">
<description>
<ul>
<li>Fixes `CreateTab` to sometimes spawn more than one tab (#1695)</li>
<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>
Expand Down
2 changes: 1 addition & 1 deletion src/contour/TerminalSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1434,7 +1434,7 @@ bool TerminalSession::operator()(actions::WriteScreen const& event)

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

Expand Down
6 changes: 5 additions & 1 deletion src/contour/TerminalSessionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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); });

Expand Down

0 comments on commit 9f3ec38

Please sign in to comment.