fix(gui): Make code folding context menu actions appear #2234
Closed
Mino260806 wants to merge 2 commits intoskylot:masterfrom
Closed
fix(gui): Make code folding context menu actions appear #2234Mino260806 wants to merge 2 commits intoskylot:masterfrom
Mino260806 wants to merge 2 commits intoskylot:masterfrom
Conversation
Owner
|
Hm, I think we can run |
Owner
|
I commit a fix in |
Contributor
Author
|
@skylot it's fine you can merge your branch, I was also hesitant about my approach |
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.
The Issue
At first, I was going to mark this as a feature, only to find out this is already implemented. However, the current implementation is erroneous, and never adds the actions. Here's the problem
Code folding is disabled by default. Its value is set using
AbstractCodeArea.setCodeFoldingEnabled().However, AbstractCodeArea prebuilds the context menu in its constructor, fired in this line.
jadx/jadx-gui/src/main/java/jadx/gui/ui/codearea/AbstractCodeArea.java
Line 93 in 61855a7
But superclass constructor is called before child constuctor, so AbstractCodeArea calls
isCodeFoldingEnabled()before child gets to change it, soisCodeFoldingEnabled()below always returns its default value offalseand code folding actions are never added.jadx/jadx-gui/src/main/java/jadx/gui/ui/codearea/AbstractCodeArea.java
Lines 139 to 145 in 61855a7
My Solution
I thought the best way to add it is to add the folding menu actions once
setCodeFoldingEnabled(true)is called. HoweverRSyntaxTextArea.appendFoldingMenu(JPopupMenu)only adds the actions to the end, so I made a workaround that removes present actions after target index, adds folding menu, and then adds present actions back.https://github.com/Mino260806/jadx/blob/9daac915ef08a048cb39581335839229ac9ecf93/jadx-gui/src/main/java/jadx/gui/ui/codearea/AbstractCodeArea.java#L142-L172
I'll open a PR in RSyntaxTextArea that creates
RSyntaxTextArea.appendFoldingMenu(JPopupMenu, int), and we would fix this workaround once merged and released.