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

Outlining treats returns like requires #67

Open
RustanLeino opened this issue Oct 28, 2021 · 1 comment · May be fixed by dafny-lang/dafny#1549
Open

Outlining treats returns like requires #67

RustanLeino opened this issue Oct 28, 2021 · 1 comment · May be fixed by dafny-lang/dafny#1549
Labels
enhancement New feature or request language server Relates to the Dafny LSP server

Comments

@RustanLeino
Copy link
Contributor

The document-outline feature allows a method to be collapsed in various places, for example, its signature, specification, and body. However, the returns keyword and the out-parameters that follow ought to be treated the same way as the in-parameters, not the same way as the specification clauses.

For example, consider this method:

a

It offers two places to collapse the code. By clicking the > by the method, not only are the specification clauses collapsed (that's fine), but so is the returns keyword and the out-parameters, as illustrated here:

b

I think it would be preferable to still show the out-parameters.

That is, the behavior to strive for is to treat out-parameters like in-parameters --- either show all of them or show none of them, but don't hide just the out-parameters.

@camrein
Copy link
Member

camrein commented Oct 29, 2021

I've quickly checked the behavior of this feature. Just for clarification, if anyone else reads this, the collapsing of code blocks is not related to the language server feature introduced by dafny-lang/dafny#1483.
The selection of collapsible blocks is a feature that VSCode provides automatically. The range/block that will be collapsed together is solely based on the code's indentation.

For example, if the out-parameters are declared on the same level as the method signature, the arrow is displayed at the line of the return:
image
That is why the body has its own arrow. Collapsing now will lead to the desired result:
image

An alternative would be leaving the out parameters on the same line as the method keyword:
image
But I guess this is undesired if there are as many out parameters as in your example.

The language server may provide the folding ranges. However, I guess this needs some (extensive) user testing on how practicable it is compared to the current behavior. The symbol table can only be reliably computed if the document can be resolved. If it fails to resolve due to syntax/resolution errors, the language server relocates the symbols from the last successful resolution based on the user edits.
I will prepare a PR for further experiments.

Edit: I've experimented a little bit with the folding ranges. I've placed the folding right on the line of the last out-parameter:
image
image
But we can consider if it makes sense to set another folding indicator on the method signature as well. I have to note that we can't place a folding indicator on line X but only collapse starting from line X + 1 or any other position. The indicator will always be placed on the line where the folding starts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request language server Relates to the Dafny LSP server
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants