dotnet / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
3.89k stars 784 forks source link

Outlining: unfinished statements re-expand collapsed sections #7078

Open Kelvin4702 opened 5 years ago

Kelvin4702 commented 5 years ago

Using the following file:

namespace OutliningTest

module File1 =

    module BeforeModule =
        let foo = "bar"

    // Before
    // comment
    type BeforeType =
        | Hello
        | World of int

    // Paste repro here (line 15)

    module AfterModule =
        let foo = "bar"

    // After
    // comment
    type AfterType =
        | Hello
        | World of int

Repro steps:

Sample in VS2019: FS_Outlining_VS2019

This seems to be supported in other editors, such as VSCode(+Ionide) or Notepad++. VSCode: FS_Outlining_VSCode

Environment: Windows 10 Enterprise (10.0.17763) Visual Studio 2019 (16.1.3) (but same on 2017) Visual F# Tools 10.4 for F# 4.6 (16.1.0-beta.19253.3+42526fe359672a05fd562dc16a91a43d0fe047a7)

cartermp commented 5 years ago

Aha, this is definitely a bug. It's subtle, but you'll notice that:

This is because we couldn't parse those constructs, and when we call our routine that operates on parsed input, it fails to give back proper spans for us to create BlockSpans out of. Since VS asks our tools for these BlockSpans, and we have little to give, it does what it can (and uncollapses code since there's no scope defined to collapse).

This is exacerbated if you turn off automatic brace completion, since the compiler won't have as much context when it attempts to parse. And this also won't reproduce in VSCode/Ionide because the collapsing routines there don't use something like parsed input to define what you can collapse/uncollapse.

kerams commented 1 year ago

The listed items, save for unfinished strings, seem to no longer be a problem with the revamped recovery rules. Can we close?