@@ -16,54 +16,57 @@ open Microsoft.FSharp.Compiler.SourceCodeServices
1616open Microsoft.FSharp .Compiler .SourceCodeServices .Structure
1717
1818module internal BlockStructure =
19- let scopeToBlockType = function
20- | Scope.Open-> BlockTypes.Imports
21- | Scope.Namespace
22- | Scope.Module-> BlockTypes.Namespace
23- | Scope.Record
24- | Scope.Interface
25- | Scope.TypeExtension
26- | Scope.RecordDefn
27- | Scope.CompExpr
28- | Scope.ObjExpr
29- | Scope.UnionDefn
30- | Scope.Attribute
31- | Scope.Type-> BlockTypes.Type
32- | Scope.New
33- | Scope.RecordField
34- | Scope.Member-> BlockTypes.Member
35- | Scope.LetOrUse
36- | Scope.Match
37- | Scope.MatchClause
38- | Scope.EnumCase
39- | Scope.UnionCase
40- | Scope.MatchLambda
41- | Scope.ThenInIfThenElse
42- | Scope.ElseInIfThenElse
43- | Scope.TryWith
44- | Scope.TryInTryWith
45- | Scope.WithInTryWith
46- | Scope.TryFinally
47- | Scope.TryInTryFinally
48- | Scope.FinallyInTryFinally
49- | Scope.IfThenElse-> BlockTypes.Conditional
50- | Scope.Tuple
51- | Scope.ArrayOrList
52- | Scope.CompExprInternal
53- | Scope.Quote
54- | Scope.SpecialFunc
55- | Scope.Lambda
56- | Scope.LetOrUseBang
57- | Scope.Val
58- | Scope.YieldOrReturn
59- | Scope.YieldOrReturnBang
60- | Scope.TryWith-> BlockTypes.Expression
61- | Scope.Do-> BlockTypes.Statement
62- | Scope.While
63- | Scope.For-> BlockTypes.Loop
64- | Scope.HashDirective-> BlockTypes.PreprocessorRegion
65- | Scope.Comment
66- | Scope.XmlDocComment-> BlockTypes.Comment
19+ let scopeToBlockType scope =
20+ if not Settings.Advanced.IsBlockStructureEnabledthen BlockTypes.Nonstructural
21+ else
22+ match scopewith
23+ | Scope.Open-> BlockTypes.Imports
24+ | Scope.Namespace
25+ | Scope.Module-> BlockTypes.Namespace
26+ | Scope.Record
27+ | Scope.Interface
28+ | Scope.TypeExtension
29+ | Scope.RecordDefn
30+ | Scope.CompExpr
31+ | Scope.ObjExpr
32+ | Scope.UnionDefn
33+ | Scope.Attribute
34+ | Scope.Type-> BlockTypes.Type
35+ | Scope.New
36+ | Scope.RecordField
37+ | Scope.Member-> BlockTypes.Member
38+ | Scope.LetOrUse
39+ | Scope.Match
40+ | Scope.MatchClause
41+ | Scope.EnumCase
42+ | Scope.UnionCase
43+ | Scope.MatchLambda
44+ | Scope.ThenInIfThenElse
45+ | Scope.ElseInIfThenElse
46+ | Scope.TryWith
47+ | Scope.TryInTryWith
48+ | Scope.WithInTryWith
49+ | Scope.TryFinally
50+ | Scope.TryInTryFinally
51+ | Scope.FinallyInTryFinally
52+ | Scope.IfThenElse-> BlockTypes.Conditional
53+ | Scope.Tuple
54+ | Scope.ArrayOrList
55+ | Scope.CompExprInternal
56+ | Scope.Quote
57+ | Scope.SpecialFunc
58+ | Scope.Lambda
59+ | Scope.LetOrUseBang
60+ | Scope.Val
61+ | Scope.YieldOrReturn
62+ | Scope.YieldOrReturnBang
63+ | Scope.TryWith-> BlockTypes.Expression
64+ | Scope.Do-> BlockTypes.Statement
65+ | Scope.While
66+ | Scope.For-> BlockTypes.Loop
67+ | Scope.HashDirective-> BlockTypes.PreprocessorRegion
68+ | Scope.Comment
69+ | Scope.XmlDocComment-> BlockTypes.Comment
6770
6871let isAutoCollapsible = function
6972| Scope.New
@@ -127,7 +130,7 @@ module internal BlockStructure =
127130let hintSpan = RoslynHelpers.TryFSharpRangeToTextSpan( sourceText, scopeRange.Range)
128131match textSpan, hintSpanwith
129132| Some textSpan, Some hintSpan->
130- let line = sourceText.Lines.GetLineFromPosition textSpan.Start
133+ let line = sourceText.Lines.GetLineFromPosition textSpan.Start
131134let bannerText =
132135match Option.ofNullable( line.Span.Intersection textSpan) with
133136| Some span-> sourceText.GetSubText( span) .ToString()+ " ..."