Skip to content

Commit ed36580

Browse files
committed
CPanel::navigateBack()/CPanel::navigateForward() silently skips non-existing folders (implemented #335)
1 parent 4d36346 commit ed36580

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

file-commander-core/src/cpanel.cpp

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,34 @@ bool CPanel::navigateBack()
146146
{
147147
if (_currentDisplayMode != NormalMode)
148148
return setPath(currentDirPathPosix(), refreshCauseOther) == FileOperationResultCode::Ok;
149-
else if (!_history.empty())
150-
return setPath(_history.navigateBack(), refreshCauseOther) == FileOperationResultCode::Ok;
151-
else
149+
150+
if (_history.empty())
152151
return false;
152+
153+
while (!_history.isAtBeginning())
154+
{
155+
const QString path = _history.navigateBack();
156+
if (pathIsAccessible(path))
157+
{
158+
return setPath(path, refreshCauseOther) == FileOperationResultCode::Ok;
159+
}
160+
}
161+
162+
return false;
153163
}
154164

155165
// Go to the next location from history, if any
156166
bool CPanel::navigateForward()
157167
{
158-
if (_currentDisplayMode == NormalMode && !_history.empty())
159-
return setPath(_history.navigateForward(), refreshCauseOther) == FileOperationResultCode::Ok;
168+
if (_currentDisplayMode != NormalMode || _history.empty())
169+
return false;
170+
171+
while (!_history.isAtEnd())
172+
{
173+
const QString path = _history.navigateForward();
174+
return setPath(path, refreshCauseOther) == FileOperationResultCode::Ok;
175+
}
176+
160177
return false;
161178
}
162179

0 commit comments

Comments
 (0)