@@ -47,68 +47,68 @@ class LineFoldCalculator {
4747 /// For each line in the document, find the indentation level using the ``levelProvider``. At each line, if the
4848 /// indent increases from the previous line, we start a new fold. If it decreases we end the fold we were in.
4949 private func buildFoldsForDocument( afterEditIn: NSRange , delta: Int ) {
50- workQueue. async {
51- guard let textView = self . textView, let foldProvider = self . foldProvider else { return }
52- var foldCache : [ FoldRange ] = [ ]
53- var currentFold : FoldRange ?
54- var currentDepth : Int = 0
55- var iterator = textView. layoutManager. linesInRange ( textView. documentRange)
56-
57- var lines = self . getMoreLines (
58- textView: textView,
59- iterator: & iterator,
60- lastDepth: currentDepth,
61- foldProvider: foldProvider
62- )
63- while let lineChunk = lines {
64- for lineInfo in lineChunk {
65- // Start a new fold, going deeper to a new depth.
66- if lineInfo. providerInfo. depth > currentDepth {
67- let newFold = FoldRange (
68- lineRange: lineInfo. lineNumber... lineInfo. lineNumber,
69- range: NSRange ( location: lineInfo. providerInfo. rangeIndice, length: 0 ) ,
70- depth: lineInfo. providerInfo. depth,
71- collapsed: lineInfo. collapsed,
72- parent: currentFold,
73- subFolds: [ ]
74- )
75-
76- if currentFold == nil {
77- foldCache. append ( newFold)
78- } else {
79- currentFold? . subFolds. append ( newFold)
80- }
81- currentFold = newFold
82- } else if lineInfo. providerInfo. depth < currentDepth {
83- // End this fold, go shallower "popping" folds deeper than the new depth
84- while let fold = currentFold, fold. depth > lineInfo. providerInfo. depth {
85- // close this fold at the current line
86- fold. lineRange = fold. lineRange. lowerBound... lineInfo. lineNumber
87- fold. range = NSRange ( start: fold. range. location, end: lineInfo. providerInfo. rangeIndice)
88- // move up
89- currentFold = fold. parent
90- }
91- }
92-
93- currentDepth = lineInfo. providerInfo. depth
94- }
95- lines = self . getMoreLines (
96- textView: textView,
97- iterator: & iterator,
98- lastDepth: currentDepth,
99- foldProvider: foldProvider
100- )
101- }
102-
103- // Clean up any hanging folds.
104- while let fold = currentFold {
105- fold. lineRange = fold. lineRange. lowerBound... textView. layoutManager. lineCount - 1
106- fold. range = NSRange ( start: fold. range. location, end: textView. documentRange. length)
107- currentFold = fold. parent
108- }
109-
110- self . rangesPublisher. send ( foldCache)
111- }
50+ // workQueue.async {
51+ // guard let textView = self.textView, let foldProvider = self.foldProvider else { return }
52+ // var foldCache: [FoldRange] = []
53+ // var currentFold: FoldRange?
54+ // var currentDepth: Int = 0
55+ // var iterator = textView.layoutManager.linesInRange(textView.documentRange)
56+ //
57+ // var lines = self.getMoreLines(
58+ // textView: textView,
59+ // iterator: &iterator,
60+ // lastDepth: currentDepth,
61+ // foldProvider: foldProvider
62+ // )
63+ // while let lineChunk = lines {
64+ // for lineInfo in lineChunk {
65+ // // Start a new fold, going deeper to a new depth.
66+ // if lineInfo.providerInfo.depth > currentDepth {
67+ // let newFold = FoldRange(
68+ // lineRange: lineInfo.lineNumber...lineInfo.lineNumber,
69+ // range: NSRange(location: lineInfo.providerInfo.rangeIndice, length: 0),
70+ // depth: lineInfo.providerInfo.depth,
71+ // collapsed: lineInfo.collapsed,
72+ // parent: currentFold,
73+ // subFolds: []
74+ // )
75+ //
76+ // if currentFold == nil {
77+ // foldCache.append(newFold)
78+ // } else {
79+ // currentFold?.subFolds.append(newFold)
80+ // }
81+ // currentFold = newFold
82+ // } else if lineInfo.providerInfo.depth < currentDepth {
83+ // // End this fold, go shallower "popping" folds deeper than the new depth
84+ // while let fold = currentFold, fold.depth > lineInfo.providerInfo.depth {
85+ // // close this fold at the current line
86+ // fold.lineRange = fold.lineRange.lowerBound...lineInfo.lineNumber
87+ // fold.range = NSRange(start: fold.range.location, end: lineInfo.providerInfo.rangeIndice)
88+ // // move up
89+ // currentFold = fold.parent
90+ // }
91+ // }
92+ //
93+ // currentDepth = lineInfo.providerInfo.depth
94+ // }
95+ // lines = self.getMoreLines(
96+ // textView: textView,
97+ // iterator: &iterator,
98+ // lastDepth: currentDepth,
99+ // foldProvider: foldProvider
100+ // )
101+ // }
102+ //
103+ // // Clean up any hanging folds.
104+ // while let fold = currentFold {
105+ // fold.lineRange = fold.lineRange.lowerBound...textView.layoutManager.lineCount - 1
106+ // fold.range = NSRange(start: fold.range.location, end: textView.documentRange.length)
107+ // currentFold = fold.parent
108+ // }
109+ //
110+ // self.rangesPublisher.send(foldCache)
111+ // }
112112 }
113113
114114 private func getMoreLines(
@@ -131,15 +131,11 @@ class LineFoldCalculator {
131131 count += 1
132132 continue
133133 }
134- let attachments = textView. layoutManager. attachments
135- . getAttachmentsOverlapping ( linePosition. range)
136- . compactMap ( { $0. attachment as? LineFoldPlaceholder } )
137-
138134 results. append (
139135 LineInfo (
140136 lineNumber: linePosition. index,
141137 providerInfo: foldInfo,
142- collapsed: !attachments . isEmpty
138+ collapsed: false
143139 )
144140 )
145141 count += 1
0 commit comments