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

Suggestions for ghost highlighting #126

Closed
RustanLeino opened this issue Jan 31, 2022 · 3 comments · Fixed by #128 · May be fixed by dafny-lang/dafny#1830
Closed

Suggestions for ghost highlighting #126

RustanLeino opened this issue Jan 31, 2022 · 3 comments · Fixed by #128 · May be fixed by dafny-lang/dafny#1830
Labels
bug Something isn't working language server Relates to the Dafny LSP server

Comments

@RustanLeino
Copy link
Contributor

I love the new ghost-highlighting feature in the Dafny extension. This feature adds a gray background for statements that are ghost. I have two further suggestions/wishes for this mode.

  • I have found that lemma bodies are all grayed out. My first thought was that this is due lemmas always being ghost. However, in writing up this Issue, I'm finding that I can't always reproduce the situation. I have now written several lemma or least lemma declarations without their bodies being turned into gray, and I've also written some method bodies where the statements do turn gray (even for assignments to non-ghost out-parameters, which are definitely not ghost statements).

    Here's one example:

    image

    So, my assessment is now that the feature is rather unreliable. I don't understand when it's recomputing this information or what to expect.

  • The other issue I have is selected code doesn't show up over the gray ghost highlighting. Usually, when I select some code, it lights up with a blue background. But when the code is displayed as ghost, then the background remains gray even when I select some code. This feels wrong to me as a user. I would like the blue selection highlighting to take priority over the gray ghost highlighting.

@MikaelMayer MikaelMayer pinned this issue Feb 1, 2022
@MikaelMayer
Copy link
Member

Thanks for reporting. I'm in favor of these changes too.

@camrein
Copy link
Member

camrein commented Feb 3, 2022

Thanks a lot for reporting.
It's definitely undesirable that the ghost information is not reliable, and even shows wrong information.
I'll try to have a look by myself. If anyone wants to give it a try, see below for things that came to my mind that might be helpful.

The decision whether something is marked as ghost or not is straightforward:
https://github.com/dafny-lang/dafny/blob/614425281b4374a47dbc824822728080ff4e5bd8/Source/DafnyLanguageServer/Language/GhostStateDiagnosticCollector.cs#L59-L62

The first thing I'd suggest to avoid marking lemmas as ghost unnecessarily, is to add a simple filter to the visitor implementation. Then we can avoid traversing down inside lemmas (and functions as well) and won't mark ghost statements inside these.

The thing about user interaction with code selection is also very undesirable. It might be possible to resolve this by changing the color of the ghost highlighting to a transparent one:

const GhostDecoration: DecorationRenderOptions = {
dark: {
backgroundColor: '#323232'
},
light: {
backgroundColor: '#f2f2f2'
}
};

@MikaelMayer
Copy link
Member

I recently merged a PR that re-renders ghost highlighting on the client side after every change so that it's not out of sync. Happy to reopen this issue if it persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working language server Relates to the Dafny LSP server
Projects
None yet
3 participants