From de3e864d6146c0b6e5533fefabf566fa8cd6ea9f Mon Sep 17 00:00:00 2001 From: Oleg Shpynov Date: Wed, 8 Jun 2011 18:29:39 +0400 Subject: [PATCH] Github Open in browser action should take current line into account --- .../plugins/github/GithubOpenInBrowserAction.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubOpenInBrowserAction.java b/plugins/github/src/org/jetbrains/plugins/github/GithubOpenInBrowserAction.java index 90e534486535..0919d1d6eb05 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/GithubOpenInBrowserAction.java +++ b/plugins/github/src/org/jetbrains/plugins/github/GithubOpenInBrowserAction.java @@ -19,6 +19,7 @@ import com.intellij.ide.BrowserUtil; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; @@ -148,6 +149,14 @@ public class GithubOpenInBrowserAction extends DumbAwareAction { if (branch.startsWith("origin/")){ branch = branch.substring(7); } - BrowserUtil.launchBrowser("https://github.com/" + repoInfo + "/blob/" + branch + path.substring(rootPath.length())); + + final StringBuilder builder = new StringBuilder(); + builder.append("https://github.com/").append(repoInfo).append("/blob/").append(branch).append(path.substring(rootPath.length())); + final Editor editor = e.getData(PlatformDataKeys.EDITOR); + if (editor != null){ + final int line = editor.getCaretModel().getLogicalPosition().line; + builder.append("#L").append(line); + } + BrowserUtil.launchBrowser(builder.toString()); } }