Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2021-07-21 21:36:46 +0000
committerThomas Wolf2021-07-21 21:36:46 +0000
commit5d96c25498ea401cd3482dc8c346f748cbceed3c (patch)
tree942aea6c4ce02f131e1878e116c97e97e8d4825f
parentac7639fe7700e4f7e4e23bd2ccc3f7be13cba583 (diff)
downloadegit-5d96c25498ea401cd3482dc8c346f748cbceed3c.tar.gz
egit-5d96c25498ea401cd3482dc8c346f748cbceed3c.tar.xz
egit-5d96c25498ea401cd3482dc8c346f748cbceed3c.zip
[blame] Follow in history only if linking with selection enabled
When navigating inside an editor showing revision information, EGit updates the history view to show the commit corresponding to the current text position. Do so only if "Link with Editor and Selection" is activated for the history view. Unfortunately there is no API to determine whether linking is enabled. I've chosen to query the corresponding preference from the Team UI plug-in. Bug: 572886 Change-Id: Ied12d17b5eeeb73dd6391e66b1c064b33375e084 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameOperation.java5
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java16
2 files changed, 21 insertions, 0 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameOperation.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameOperation.java
index 22a1f5260d..90ea2709be 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameOperation.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameOperation.java
@@ -33,6 +33,7 @@ import org.eclipse.egit.core.op.IEGitOperation;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.internal.EgitUiEditorUtils;
+import org.eclipse.egit.ui.internal.history.GitHistoryPage;
import org.eclipse.egit.ui.internal.history.HistoryPageInput;
import org.eclipse.egit.ui.internal.revision.FileRevisionEditorInput;
import org.eclipse.jface.text.BadLocationException;
@@ -149,6 +150,10 @@ public class BlameOperation implements IEGitOperation {
if (!(first instanceof BlameRevision))
return;
+ if (!GitHistoryPage.isLinkingEnabled()) {
+ return;
+ }
+
IHistoryView part = (IHistoryView) PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage()
.findView(IHistoryView.VIEW_ID);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
index 6e6ed567c5..0c4ae11c5c 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
@@ -45,6 +45,7 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
@@ -182,6 +183,21 @@ import org.eclipse.ui.texteditor.IUpdate;
public class GitHistoryPage extends HistoryPage implements RefsChangedListener,
TableLoader, IShowInSource, IShowInTargetList {
+ private static final String TEAM_UI_PLUGIN_ID = "org.eclipse.team.ui"; //$NON-NLS-1$
+
+ private static final String TEAM_UI_LINKING_PREFERENCE = "pref_generichistory_view_linking"; //$NON-NLS-1$
+
+ /**
+ * Tells whether "Link with Editor and Selection" is currently enabled in
+ * the history view.
+ *
+ * @return {@code true} if linking is enabled, {@code false} otherwise.
+ */
+ public static boolean isLinkingEnabled() {
+ return Platform.getPreferencesService().getBoolean(TEAM_UI_PLUGIN_ID,
+ TEAM_UI_LINKING_PREFERENCE, false, null);
+ }
+
private static final int INITIAL_ITEM = -1;
private static final String P_REPOSITORY = "GitHistoryPage.Repository"; //$NON-NLS-1$

Back to the top