summaryrefslogtreecommitdiff
path: root/src/plugins/bookmarks/bookmarkmanager.cpp
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2018-04-30 15:39:10 +0200
committerEike Ziller <eike.ziller@qt.io>2018-05-02 07:10:43 +0000
commit658d5b5d2c4088e659883fbdc7948805ca92af29 (patch)
tree740163e441191f80e4435a6e53646330b876e099 /src/plugins/bookmarks/bookmarkmanager.cpp
parent80b9f047f6b3cb39d95b6636fb18fffa7cbf7dbb (diff)
downloadqt-creator-658d5b5d2c4088e659883fbdc7948805ca92af29.tar.gz
Bookmarks: Improve behavior of "Previous Bookmark"
If the text cursor is currently not at the "current bookmark", it is more intuitive and useful if "Previous Bookmark" first moves to the current bookmark, instead of jumping to the one before that. That solves two issues: - creating a bookmark, jumping somewhere else, and then going back to that bookmark - deleting a bookmark, and then going to the previous one Task-number: QTCREATORBUG-20061 Change-Id: I6dbb8c94f4d50ae4cc36e52808029e685be11069 Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/bookmarks/bookmarkmanager.cpp')
-rw-r--r--src/plugins/bookmarks/bookmarkmanager.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/plugins/bookmarks/bookmarkmanager.cpp b/src/plugins/bookmarks/bookmarkmanager.cpp
index deb19a80f8..f0b2f9d71f 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)