diff --git a/mailnews/base/src/nsMsgDBView.cpp b/mailnews/base/src/nsMsgDBView.cpp index 94ed545ab40..451c26f749c 100644 --- a/mailnews/base/src/nsMsgDBView.cpp +++ b/mailnews/base/src/nsMsgDBView.cpp @@ -3574,7 +3574,7 @@ nsresult nsMsgDBView::NavigateFromPos(nsMsgNavigationTypeValue motion, nsMsgView *pResultKey = m_keys.GetAt(*pResultIndex); break; case nsMsgNavigationType::previousMessage: - *pResultIndex = (startIndex > 0) ? startIndex - 1 : 0; + *pResultIndex = (startIndex != nsMsgViewIndex_None) ? startIndex - 1 : 0; *pResultKey = m_keys.GetAt(*pResultIndex); break; case nsMsgNavigationType::lastMessage: @@ -3654,6 +3654,9 @@ nsresult nsMsgDBView::NavigateFromPos(nsMsgNavigationTypeValue motion, nsMsgView } break; case nsMsgNavigationType::previousUnreadMessage: + if (startIndex == nsMsgViewIndex_None) { + break; + } rv = FindPrevUnread(m_keys.GetAt(startIndex), pResultKey, &resultThreadKey); if (NS_SUCCEEDED(rv)) {