diff --git a/src/plugins/bookmarks/bookmarkmanager.cpp b/src/plugins/bookmarks/bookmarkmanager.cpp index deb19a80f8d..f0b2f9d71f3 100644 --- a/src/plugins/bookmarks/bookmarkmanager.cpp +++ b/src/plugins/bookmarks/bookmarkmanager.cpp @@ -603,7 +603,8 @@ void BookmarkManager::prev() QModelIndex current = selectionModel()->currentIndex(); if (!current.isValid()) return; - + if (!isAtCurrentBookmark() && gotoBookmark(bookmarkForIndex(current))) + return; int row = current.row(); while (true) { if (row == 0) @@ -806,6 +807,17 @@ void BookmarkManager::loadBookmarks() updateActionStatus(); } +bool BookmarkManager::isAtCurrentBookmark() const +{ + Bookmark *bk = bookmarkForIndex(selectionModel()->currentIndex()); + if (!bk) + return true; + IEditor *currentEditor = EditorManager::currentEditor(); + return currentEditor + && currentEditor->document()->filePath() == Utils::FileName::fromString(bk->fileName()) + && currentEditor->currentLine() == bk->lineNumber(); +} + // BookmarkViewFactory BookmarkViewFactory::BookmarkViewFactory(BookmarkManager *bm) diff --git a/src/plugins/bookmarks/bookmarkmanager.h b/src/plugins/bookmarks/bookmarkmanager.h index 0a87614f47d..0bbd2468f68 100644 --- a/src/plugins/bookmarks/bookmarkmanager.h +++ b/src/plugins/bookmarks/bookmarkmanager.h @@ -105,6 +105,7 @@ signals: private: void updateActionStatus(); void loadBookmarks(); + bool isAtCurrentBookmark() const; void documentPrevNext(bool next);