feat: add support for diff editor detection#297
Open
twangodev wants to merge 4 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for detecting diff editor views in JetBrains IDEs and updating the Discord Rich Presence status to show "Comparing filename" when viewing diffs. The feature enhances user status accuracy by distinguishing between regular file editing and diff comparison activities.
Changes:
- Added
isDiffEditorboolean field to theData.Filedata class to track diff editor state - Implemented diff editor detection logic using class name pattern matching
- Enhanced filename extraction for diff editors using EditorTabTitleProvider and regex pattern matching
- Updated presence text logic to display "Comparing" prefix for diff editors
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| plugin/common/src/main/kotlin/dev/azn9/plugins/discord/data/Data.kt | Added isDiffEditor field to Data.File class and updated toString method |
| plugin/common/src/main/kotlin/dev/azn9/plugins/discord/data/DataService.kt | Core implementation: diff detection, filename extraction via EditorTabTitleProvider, and regex pattern for parsing filenames from tooltips |
| plugin/common/src/main/kotlin/dev/azn9/plugins/discord/settings/values/PresenceText.kt | Updated prefix logic to prioritize "Comparing" for diff editors over "Editing"/"Reading" |
| plugin/common/src/main/kotlin/dev/azn9/plugins/discord/render/templates/CustomTemplate.kt | Added IsDiffEditor template variable support for custom templates |
| plugin/common/src/main/kotlin/dev/azn9/plugins/discord/settings/gui/preview/PreviewRenderer.kt | Added isDiffEditor default value in preview renderer |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…lename Previously, if the regex failed to match a filename in the tab tooltip, the entire tooltip text was used as the displayed name, which could be arbitrarily long.
The previous pattern \b[\w\-]+\.[\w.]+\b accepted strings like "file..txt" because the trailing character class included the dot itself. The new pattern requires each dot to be followed by at least one word/hyphen character, while still supporting multi-extension names like "file.tar.gz".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds support for viewing diffs by updating status to "Comparing
filename" when viewing diffsOriginal Behavior
The following would appear when the following was open:
New Behavior
We employ a new technique for capturing filename when reading a diff.
This also works with diffs generated by Claude Code, Junie through their native integrations.