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

fix: Editor is already disposed in LSP hover operation (#914) #924

Merged

Conversation

angelozerr
Copy link

fix: Editor is already disposed in LSP hover operation (#914)

Fixes #914

@angelozerr
Copy link
Author

As IJ hover provider API doesn't provide the target offset (it provies the hovered PsiElement), the master code defines the getCursorOffset https://github.com/redhat-developer/intellij-quarkus/pull/924/files#diff-3226f92e605d133b246286d765a9045cc993a8fc0804b4ef662b3d6403639857L121 which uses invokeLater https://github.com/redhat-developer/intellij-quarkus/pull/924/files#diff-3226f92e605d133b246286d765a9045cc993a8fc0804b4ef662b3d6403639857L123

The main idea of this PR is to remove thisCompletableFuture which get the cursor.

To remove rhis getCursorOffet, the idea is to implement https://github.com/redhat-developer/intellij-quarkus/pull/924/files#diff-3226f92e605d133b246286d765a9045cc993a8fc0804b4ef662b3d6403639857L123 to get the target offset.

}

@Nullable
@Override
public String generateDoc(PsiElement element, @Nullable PsiElement originalElement) {
Editor editor = LSPIJUtils.editorForElement(element);
if (editor != null) {
initiateHoverRequest(element, editor);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't you use int offset = PsiUtilCore.getElementOffsetInFile(element); instead ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hover should work without PsiElement to avoid client to implement a Psi parser. We need just the hovered offset and we don't use PsiElement.

@angelozerr angelozerr force-pushed the texthover-improve-cursoroffset branch 3 times, most recently from 4a93a99 to 2e3d776 Compare June 7, 2023 14:31
@angelozerr angelozerr marked this pull request as ready for review June 7, 2023 14:37
@angelozerr angelozerr requested a review from fbricon June 7, 2023 14:37
@sonarcloud
Copy link

sonarcloud bot commented Jun 7, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@angelozerr
Copy link
Author

@fbricon are you agree with my changes?

I would like to include this PR in the release

@fbricon
Copy link
Contributor

fbricon commented Jun 7, 2023

LGTM

@fbricon fbricon merged commit d4b2d8f into redhat-developer:main Jun 8, 2023
15 checks passed
@fbricon
Copy link
Contributor

fbricon commented Jun 8, 2023

Thanks @angelozerr!

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

Successfully merging this pull request may close these issues.

Editor is already disposed in LSP hover operation
2 participants