Fsharp: Collapse to Definitions does not work.

Created on 4 Apr 2017  路  13Comments  路  Source: dotnet/fsharp

With VS 2017 nightly, Collapse to Definitions does not work.

Repro steps

  1. Open any FSharp file with some functions.
  2. Hit CTRL M + CTRL O (alternatively right click to screen -> outlining -> collapse to definitions.

Expected behavior

All code should be collapsed to their definitions.

Actual behavior

Nothing happens.

Known workarounds

No.

Related information

VS 2017 RTM with F# nightly tools.

Area-IDE Language Service

Most helpful comment

Awesome! You rock! :)

All 13 comments

@Pilchie any points why it does not work? Should our structure service provide some special tags or whatever to make it work?

In addition to above, another problem is, if you make a mistake in your code while typing, all collapsed regions expand automatically after few seconds. Then you have to collapse them again.

Perhaps this is a different issue but surely it is annoying. IDE should not automatically expand anything even if there is a compile error.

We don't control collapsing behavior.

Hmm though this is certainly annoying. Suppose that you have a long file and you collapsed some functions, then make a slight mistake and all collapses are gone. Where should I report this then ?

dotnet/roslyn

Ah will do so. But note that this behavior only happens with F#.

F# parser is very sensitive to errors. So, it's quite easy to bring source code to a state when the parser does not return anything. If it returns nothing, we provide no structure (on which outlining is based) for the file and roslyn/VS decides to remove everything. When the code is fixed, we return good structure again, but roslyn/VS seem to be unable to match the new structure with the old one to collapse previously collapsed regions. We had the same issue in VFPT and I think we were caching regions and returned old ones if the parser returns nothing. @cloudRoutine do you remember the details?

Tagging @cyrusnajmabadi too, but yes, - you need to indicate whether a region should be considered a "definition" or not.

When the code is fixed, we return good structure again, but roslyn/VS seem to be unable to match the new structure with the old one to collapse previously collapsed regions.

Correct. If you go from no regions to some regions, there is no 'matching' done. The only matching happens if you have existing regions and continuously produce updated regions. This is how Roslyn's async-tagging architecture works.

You'll have to implement some sort of caching if your system cannot provide continuous, reasonable, structure tags.

@vasily-kirichenko

any points why it does not work? Should our structure service provide some special tags or whatever to make it work?

You'll need to set this property on BlockSpan. Thanks!

c# /// <summary> /// Whether or not this region should be automatically collapsed when the 'Collapse to Definitions' command is invoked. /// </summary> public bool AutoCollapse { get; }

Fixed in https://github.com/Microsoft/visualfsharp/pull/2810 ("collapse to definition")

@CyrusNajmabadi Thanks, it works :)

Awesome! You rock! :)

Was this page helpful?
0 / 5 - 0 ratings