diff options
author | Tobias Hunger <tobias.hunger@theqtcompany.com> | 2015-04-16 15:06:25 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@theqtcompany.com> | 2015-04-20 07:56:46 +0000 |
commit | 5ba30d9278de4de5b773d306e8b678f58d740d62 (patch) | |
tree | 72f79fe6ccac2424d2d17f22f4ace4d6e0d81b37 /src/plugins/vcsbase | |
parent | 3b68a46ba1fc3f6b78f9166cb5e5850222a7f211 (diff) |
Vcs: Find better line-number to scroll annotate output to
Use new TextEditorWidget::firstVisibleLine, etc. methods to find
a better line to center on.
Task-number: QTCREATORBUG-14230
Change-Id: I36424fcd1200d362d06c456e7b4c13e671dbd4b6
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
Diffstat (limited to 'src/plugins/vcsbase')
-rw-r--r-- | src/plugins/vcsbase/vcsbaseeditor.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp index 98ae597214..8fe872caed 100644 --- a/src/plugins/vcsbase/vcsbaseeditor.cpp +++ b/src/plugins/vcsbase/vcsbaseeditor.cpp @@ -1287,7 +1287,16 @@ int VcsBaseEditor::lineNumberOfCurrentEditor(const QString ¤tFile) const BaseTextEditor *eda = qobject_cast<const BaseTextEditor *>(ed); if (!eda) return -1; - return eda->currentLine(); + const int cursorLine = eda->currentLine(); + auto const edw = qobject_cast<const TextEditorWidget *>(ed->widget()); + if (edw) { + const int firstLine = edw->firstVisibleLine(); + const int lastLine = edw->lastVisibleLine(); + if (firstLine <= cursorLine && cursorLine < lastLine) + return cursorLine; + return edw->centerVisibleLine(); + } + return cursorLine; } bool VcsBaseEditor::gotoLineOfEditor(Core::IEditor *e, int lineNumber) |