Commit e70e12e3 authored by Felix Ernst's avatar Felix Ernst 🇺🇦
Browse files

Fix terminal panel not keeping up with dir changes

The terminal panel is supposed to show the same location as the
currently active Dolphin view at all times.

However there was an issue when the terminal is supposed to
quickly switch to a new location and then back again to the old
one. The terminal ignored the switch to the old location unless it
had already fully switched to the new location. Because it isn't
particularly fast at fully switching to the new location, it would
never do the expected thing of switching back to the old location.

This commit makes it so the switch to the old location is only
ignored if there are no in-progress switches to a different

BUG: 391380

BUG: 416690

FIXED-IN: 22.04.2

Not totally sure if this fixes everything but it seems like an improvement.
parent 4012ea30
Pipeline #169010 passed with stage
in 4 minutes and 11 seconds
......@@ -234,7 +234,9 @@ void TerminalPanel::changeDir(const QUrl& url)
void TerminalPanel::sendCdToTerminal(const QString& dir, HistoryPolicy addToHistory)
if (dir == m_konsolePartCurrentDirectory) {
if (dir == m_konsolePartCurrentDirectory // We are already there
&& m_sendCdToTerminalHistory.isEmpty() // …and that is not because the terminal couldn't keep up
) {
m_clearTerminal = false;
......@@ -252,8 +254,6 @@ void TerminalPanel::sendCdToTerminal(const QString& dir, HistoryPolicy addToHist
m_terminal->sendInput(" cd " + KShell::quoteArg(dir) + '\n');
// We want to ignore the currentDirectoryChanged(QString) signal, which we will receive after
// the directory change, because this directory change is not caused by a "cd" command that the
// user entered in the panel. Therefore, we have to remember 'dir'. Note that it could also be
......@@ -261,6 +261,8 @@ void TerminalPanel::sendCdToTerminal(const QString& dir, HistoryPolicy addToHist
if (addToHistory == HistoryPolicy::AddToHistory)
m_terminal->sendInput(" cd " + KShell::quoteArg(dir) + '\n');
if (m_clearTerminal) {
m_terminal->sendInput(QStringLiteral(" clear\n"));
m_clearTerminal = false;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment