@@ -9,47 +9,6 @@ import Foundation
99import AppKit
1010import CodeEditTextView
1111
12- final class IndentationLineFoldProvider : LineFoldProvider {
13- func foldLevelAtLine( _ lineNumber: Int , layoutManager: TextLayoutManager , textStorage: NSTextStorage ) -> Int ? {
14- guard let linePosition = layoutManager. textLineForIndex ( lineNumber) ,
15- let indentLevel = indentLevelForPosition ( linePosition, textStorage: textStorage) else {
16- return nil
17- }
18-
19- // if let precedingLinePosition = layoutManager.textLineForIndex(lineNumber - 1),
20- // let precedingIndentLevel = indentLevelForPosition(precedingLinePosition, textStorage: textStorage) {
21- // if precedingIndentLevel > indentLevel {
22- // return precedingIndentLevel
23- // }
24- // }
25- //
26- // if let nextLinePosition = layoutManager.textLineForIndex(lineNumber + 1),
27- // let nextIndentLevel = indentLevelForPosition(nextLinePosition, textStorage: textStorage) {
28- // if nextIndentLevel > indentLevel {
29- // return nextIndentLevel
30- // }
31- // }
32-
33- return indentLevel
34- }
35-
36- private func indentLevelForPosition(
37- _ position: TextLineStorage < TextLine > . TextLinePosition ,
38- textStorage: NSTextStorage
39- ) -> Int ? {
40- guard let substring = textStorage. substring ( from: position. range) else {
41- return nil
42- }
43-
44- return substring. utf16 // Keep NSString units
45- . enumerated ( )
46- . first ( where: { UnicodeScalar ( $0. element) ? . properties. isWhitespace != true } ) ?
47- . offset
48- }
49- }
50-
51- let buh = IndentationLineFoldProvider ( )
52-
5312/// Displays the code folding ribbon in the ``GutterView``.
5413///
5514/// This view draws its contents
@@ -93,7 +52,7 @@ class FoldingRibbonView: NSView {
9352 init ( textView: TextView , foldProvider: LineFoldProvider ? ) {
9453 self . model = LineFoldingModel (
9554 textView: textView,
96- foldProvider: buh
55+ foldProvider: foldProvider
9756 )
9857 super. init ( frame: . zero)
9958 layerContentsRedrawPolicy = . onSetNeedsDisplay
0 commit comments