diff --git a/plugins/github/resources/META-INF/plugin.xml b/plugins/github/resources/META-INF/plugin.xml
index 32443254e586..aadd77d90102 100644
--- a/plugins/github/resources/META-INF/plugin.xml
+++ b/plugins/github/resources/META-INF/plugin.xml
@@ -202,5 +202,11 @@
+
+
\ No newline at end of file
diff --git a/plugins/github/resources/messages/GithubBundle.properties b/plugins/github/resources/messages/GithubBundle.properties
index a15599bc1350..9afd319c0efe 100644
--- a/plugins/github/resources/messages/GithubBundle.properties
+++ b/plugins/github/resources/messages/GithubBundle.properties
@@ -286,6 +286,7 @@ pull.request.diff.editor.add.single.comment=Add a single comment
pull.request.diff.editor.review.comment=Comment
pull.request.diff.editor.review.start=Start review
pull.request.diff.editor.review.with.comment=Start a review with a comment
+action.Github.PullRequest.Diff.Comment.Create.text=Add Review Comment
pull.request.review.submit.request.changes=Request Changes
pull.request.review.submit.approve.button=Approve
pull.request.review.submit.comment.button=Comment
diff --git a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/comment/action/GHPRCreateDiffCommentAction.kt b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/comment/action/GHPRCreateDiffCommentAction.kt
new file mode 100644
index 000000000000..7049e7513171
--- /dev/null
+++ b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/comment/action/GHPRCreateDiffCommentAction.kt
@@ -0,0 +1,57 @@
+// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+package org.jetbrains.plugins.github.pullrequest.comment.action
+
+import com.intellij.openapi.actionSystem.*
+import com.intellij.openapi.actionSystem.ex.ActionUtil
+import com.intellij.openapi.editor.Editor
+import com.intellij.openapi.editor.ScrollType
+import com.intellij.openapi.editor.ex.EditorEx
+import com.intellij.openapi.editor.ex.RangeHighlighterEx
+import com.intellij.openapi.project.DumbAwareAction
+import com.intellij.util.CommonProcessors
+import org.jetbrains.plugins.github.pullrequest.comment.ui.GHPRAddCommentGutterIconRenderer
+
+class GHPRCreateDiffCommentAction : DumbAwareAction() {
+
+ override fun update(e: AnActionEvent) {
+ e.presentation.isEnabledAndVisible = isEnabledAndVisible(e)
+ }
+
+ private fun isEnabledAndVisible(e: AnActionEvent): Boolean {
+ val editor = e.getData(CommonDataKeys.EDITOR) ?: return false
+ return findRendererActionUnderCaret(editor) != null
+ }
+
+ override fun actionPerformed(e: AnActionEvent) {
+ val editor = e.getRequiredData(CommonDataKeys.EDITOR)
+ val action = findRendererActionUnderCaret(editor) ?: return
+
+ val scrollingModel = editor.scrollingModel
+ scrollingModel.scrollToCaret(ScrollType.MAKE_VISIBLE)
+ scrollingModel.runActionOnScrollingFinished {
+ if (action is ActionGroup) {
+ val point = editor.visualPositionToXY(editor.caretModel.visualPosition)
+ ActionManager.getInstance().createActionPopupMenu(ActionPlaces.EDITOR_GUTTER_POPUP, action).component
+ .show(editor.component, point.x, point.y - scrollingModel.verticalScrollOffset)
+ }
+ else ActionUtil.invokeAction(action, editor.component, ActionPlaces.EDITOR_GUTTER, e.inputEvent, null)
+ }
+ }
+
+ private fun findRendererActionUnderCaret(editor: Editor): AnAction? {
+ val markupModel = (editor as? EditorEx)?.markupModel ?: return null
+ val logicalPosition = editor.caretModel.logicalPosition
+ val line = logicalPosition.line
+ val offset = editor.logicalPositionToOffset(logicalPosition)
+ val findProcessor = object : CommonProcessors.FindProcessor() {
+ override fun accept(t: RangeHighlighterEx): Boolean {
+ val gutterIconRenderer = t.gutterIconRenderer
+ return gutterIconRenderer is GHPRAddCommentGutterIconRenderer && gutterIconRenderer.line == line
+ }
+ }
+ markupModel.processRangeHighlightersOverlappingWith(offset, offset, findProcessor)
+
+ val renderer = findProcessor.foundValue?.gutterIconRenderer ?: return null
+ return renderer.clickAction ?: renderer.popupMenuActions
+ }
+}
\ No newline at end of file