Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hyperlinks stopped working with 3.1.0+ #443

Closed
ThexXTURBOXx opened this issue Apr 6, 2022 · 4 comments
Closed

Hyperlinks stopped working with 3.1.0+ #443

ThexXTURBOXx opened this issue Apr 6, 2022 · 4 comments
Assignees
Labels
Milestone

Comments

@ThexXTURBOXx
Copy link
Contributor

Description
Using RSTA 3.0.8, hyperlinks in Luyten were working properly. However, when updating to 3.1.0 (or even 3.2.0), using the same code, they are not working correctly anymore.

Steps to Reproduce
Specific steps to reproduce the behavior:

  1. Add a LinkGenerator to a RSyntaxTextArea and enable hyperlinks
  2. Click on a hyperlink

Expected behavior
The LinkGeneratorResult#execute function should be executed

Actual behavior
The LinkGeneratorResult#execute function is not executed in RSTA >=3.1.0

Java version
Tested with Java 8 and Java 17

Additional context
From what I can gather using some debugging code, RSyntaxTextArea#hoveredOverLinkOffset gets reset to -1 when the hyperlink is clicked, probably through RSyntaxTextArea#stopScanningForLinks (however I am not sure!).
Because of this, RSyntaxTextAreaMutableCaretEvent#mouseClicked will not fire the ACTIVATED event.
I am unsure if I am correct, but I think, this is what's going wrong there.
Relevant code can be found here: https://github.com/ThexXTURBOXx/Luyten/blob/main/src/main/java/us/deathmarine/luyten/OpenFile.java#L131

@ThexXTURBOXx
Copy link
Contributor Author

After looking through the existing issues, I noticed that #441 looks very much just like this one right here.
Maybe they are related?

@ThexXTURBOXx
Copy link
Contributor Author

Adding an empty Hyperlink listener fixes the issue.
Thus, the issue lies most likely in this change: 9bc9f18#diff-04814d39a10acb9fcadce1be9b81a60c97ea2070b99a3af1ff6bbabc0daa2ab7R926

@bobbylight bobbylight self-assigned this Apr 17, 2022
@bobbylight
Copy link
Owner

Better late than never! Thanks @ThexXTURBOXx ! You hit the nail on the head. That code was lazily creating the HyperlinkEvent only if there were HyperlinkListeners registered, but that caused LinkGeneratorResults to not be executed. It wasn't taking into account the contract that they could handle click events themselves. The fix was simply to not lazily evaluate the LinkGeneratorResult.

@ThexXTURBOXx
Copy link
Contributor Author

Thank you very much for the update and the fix! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants