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

Show implicit decorations in worksheets #3582

Merged
merged 2 commits into from
Feb 1, 2022

Conversation

tgodzik
Copy link
Contributor

@tgodzik tgodzik commented Jan 30, 2022

Previously, we would not show implicit decorations in worksheet files, because they could get overriden by the worksheet decorations. Now, we send two different types of decorations, inline and not inline, which makes sure that one will not override the other.

This got tested in VS Code, but we would also need a confirmation on how to make it work in Sublime text.

Fixes #3581

tgodzik added a commit to tgodzik/metals-vscode that referenced this pull request Jan 30, 2022
Previously, we would have a separate type of decorations for worksheets. Now, we have a separate type for worksheets evaluations and synthetic decorations.

Needed for scalameta/metals#3582
@tgodzik tgodzik added the affects clients Use this if you are adding a new setting or making a change that will affect clients. label Jan 31, 2022
@tgodzik tgodzik requested a review from ckipp01 January 31, 2022 13:02
Copy link
Member

@ckipp01 ckipp01 left a comment

Choose a reason for hiding this comment

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

One final nit that isn't a blocker, but LGTM!

docs/integrations/decoration-protocol.md Outdated Show resolved Hide resolved
Previously, we would not show implicit decorations in worksheet files, because they could get overriden by the worksheet decorations. Now, we send two different types of decorations, inline and not inline, which makes sure that one will not override the other.

This got tested in VS Code, but we would also need a confirmation on how to make it work in Sublime text.
tests/unit/src/main/scala/tests/TestingClient.scala Outdated Show resolved Hide resolved
@@ -48,7 +49,9 @@ class SemanticdbTextDocumentProvider(
} else {
None
}
val document = unit.toTextDocument(explicitDialect)
// we recalculate md5, since there seems to be issue with newlines sometimes
Copy link
Member

Choose a reason for hiding this comment

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

What problems were caused by this newlines problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Different md5 results produced by default when no newline was at the end. Not sure exactly why.

Copy link
Member

Choose a reason for hiding this comment

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

It makes sense that inserting a character changes the document hash, but I still don't see when the problem starts. When is this newline inserted? unit.toTextDocument has md5 = unit.source.toMD5, so it indicates that file content is changed after compilation unit is created. Is this vscode problematic behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When is this newline inserted?

I don't know :D That is the reason, and I am not even sure if it's a newline. Just that on the same text we were calculating two different md5 results.

Copy link
Member

Choose a reason for hiding this comment

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

Do you have steps for reproduction? It bothers me a lot :c

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I create worksheet with last statement without a newline this started popping up. It's not strickly related tot his PR so I can revert the change

Copy link
Member

Choose a reason for hiding this comment

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

It's okay, there is no need for reverting. I just want to investigate it ;)

if (decorationTypes == null) {
Set(params)
} else {
decorationTypes.filter(p => p.isInline != params.isInline) + params
Copy link
Member

Choose a reason for hiding this comment

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

Why are you filtering decorations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To replace the particular inline type. If isInline=true we will only replace decorations with inline=true and vice versa

Co-authored-by: Kamil Podsiadło <37124721+kpodsiad@users.noreply.github.com>
@tgodzik tgodzik requested a review from kpodsiad February 1, 2022 11:39
@tgodzik tgodzik merged commit 3035af4 into scalameta:main Feb 1, 2022
@tgodzik tgodzik deleted the worksheet-decorations branch February 1, 2022 15:01
@kubukoz
Copy link
Contributor

kubukoz commented Feb 1, 2022

image

Pretty nice :D I understand there's no hover yet?

@tgodzik
Copy link
Contributor Author

tgodzik commented Feb 1, 2022

image

Pretty nice :D I understand there's no hover yet?

There should be, though it also shouldn't yet work :D We also need the VS Code PR

@ayoub-benali
Copy link
Contributor

@tgodzik How is the editor supposed to treat the new inline argument ?

@tgodzik
Copy link
Contributor Author

tgodzik commented Apr 25, 2022

@tgodzik How is the editor supposed to treat the new inline argument ?

It's just an information for the editor so that we don't override worksheet decorations with synthetic ones and vice versa. They are being sent at a different time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects clients Use this if you are adding a new setting or making a change that will affect clients.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support synthetics in worksheets
5 participants