[FEATURE] JetBrains plugin: send selection context from the IDE diff view
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
This was requested in #54663, but a bot auto-closed it as a duplicate of #23192 and then locked it. #23192 is about a different problem: Claude's proposed edits not opening in the IntelliJ diff viewer on Windows. Neither of the other suggested duplicates (#6009, #37041) covers this either, so I'm opening it again.
Problem Statement
In JetBrains IDEs, selecting lines in a normal editor tab sends them to Claude Code as context. Selecting lines in the IDE's diff view (Git diffs, Compare with Branch, PR review diffs) sends nothing. Neither the automatic selection context nor Cmd+Option+K / "Send to Claude Code" works there.
That means you can't ask Claude about the lines you're looking at during a code review in the IDE, which is where a lot of reviewing happens.
Proposed Solution
Send selection_changed (and allow the at-mention action) for selections made in diff editors too.
From the plugin's class files (0.1.14-beta), it looks like the selection listener is only attached to TextEditor instances from FileEditorManager, and SendToClaudeAction uses FileEditorManager.getSelectedTextEditor(). Editors inside a diff viewer aren't covered by either. Some options:
- Listen through
EditorFactory.getEventMulticaster().addSelectionListener(...)and include editors withEditorKind.DIFF, or attach listeners to the viewer's editors from the existingDiffExtension. - In
SendToClaudeAction, useCommonDataKeys.EDITORfrom the action event so it picks up the focused diff editor. - For the side that is the local working copy,
FileDocumentManager.getFile(document)already returns the real file, so path and line numbers work as they do today. For a historical revision side, sending the real file path plus the selected text would be enough. Line numbers could be marked as belonging to that revision.
Alternative Solutions
- Press F4 (Jump to Source) to open the local file, then select the same lines again. This breaks the flow, and it doesn't work for lines that only exist on the old side.
- Copy and paste the code into the prompt by hand.
Priority
Medium - Would be very helpful
Feature Category
Other
Use Case Example
- Check out a PR branch and open Git > Compare with Branch… (or the GitHub PR diff) in PyCharm.
- Select a changed block in the diff view.
- In the Claude Code terminal, ask "is this change safe?" and expect Claude to see the selected lines, as it does from a normal editor tab.
Additional Context
- PyCharm 2026.2.3, Claude Code [Beta] plugin 0.1.14-beta, Claude Code 2.1.285, macOS
- This affects every JetBrains IDE (IntelliJ IDEA, PyCharm, WebStorm, GoLand, …).
_--Claude_