OSDN Git Service

VCS: Do not jump to any file when in the diff header
authorTobias Hunger <tobias.hunger@nokia.com>
Fri, 8 Apr 2011 08:40:59 +0000 (10:40 +0200)
committerTobias Hunger <tobias.hunger@nokia.com>
Fri, 8 Apr 2011 08:58:05 +0000 (10:58 +0200)
Do not jump to a file on double-click when in a diff header.

Task-number: QTCREATORBUG-4364

src/plugins/vcsbase/vcsbaseeditor.cpp

index 5b1dccd..428e26a 100644 (file)
@@ -49,6 +49,7 @@
 #include <projectexplorer/projectexplorer.h>
 #include <projectexplorer/project.h>
 #include <projectexplorer/session.h>
+#include <texteditor/basetextdocumentlayout.h>
 #include <texteditor/fontsettings.h>
 #include <texteditor/texteditorconstants.h>
 #include <utils/qtcassert.h>
@@ -708,6 +709,9 @@ void VCSBaseEditorWidget::jumpToChangeFromDiff(QTextCursor cursor)
     const QChar deletionIndicator = QLatin1Char('-');
     // find nearest change hunk
     QTextBlock block = cursor.block();
+    if (TextEditor::BaseTextDocumentLayout::foldingIndent(block) <= 1)
+        /* We are in a diff header, do not jump anywhere. DiffHighlighter sets the foldingIndent for us. */
+        return;
     for ( ; block.isValid() ; block = block.previous()) {
         const QString line = block.text();
         if (checkChunkLine(line, &chunkStart)) {