Skip to content

Commit 8abf180

Browse files
committed
Remove some comments
1 parent 3b13a30 commit 8abf180

File tree

3 files changed

+24
-26
lines changed

3 files changed

+24
-26
lines changed

Sources/CodeEditSourceEditor/LineFolding/FoldProviders/IndentationLineFoldProvider.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ extension NSString: @retroactive TextStoring {
1313
public func substring(from range: NSRange) -> String? {
1414
self.substring(with: range)
1515
}
16-
16+
1717
public func applyMutation(_ mutation: TextMutation) {
1818
self.replacingCharacters(in: mutation.range, with: mutation.string)
1919
}
@@ -37,7 +37,7 @@ final class IndentationLineFoldProvider: LineFoldProvider {
3737
controller: TextViewController
3838
) -> [LineFoldProviderLineInfo] {
3939
let text = controller.textView.textStorage.string as NSString
40-
guard let leadingIndent = text.leadingRange(in: lineRange, within: .whitespacesWithoutNewlines)?.length,
40+
guard let leadingIndent = text.leadingRange(in: lineRange, within: .whitespacesAndNewlines)?.length,
4141
leadingIndent != lineRange.length else {
4242
return []
4343
}

Sources/CodeEditSourceEditor/LineFolding/Model/LineFoldCalculator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ actor LineFoldCalculator {
6666
foldProvider: foldProvider
6767
)
6868
while let lineChunk = lines {
69-
for lineInfo in lineChunk where lineInfo.depth > 0 {
69+
for lineInfo in lineChunk {
7070
// Start a new fold, going deeper to a new depth.
7171
if lineInfo.depth > currentDepth {
7272
let newFold = LineFoldStorage.RawFold(

Sources/CodeEditSourceEditor/LineFolding/View/FoldingRibbonView+Draw.swift

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,23 @@ extension FoldingRibbonView {
3939
}
4040
let textRange = rangeStart.range.location..<rangeEnd.range.upperBound
4141

42+
let folds = getDrawingFolds(forTextRange: textRange)
43+
for fold in folds {
44+
drawFoldMarker(
45+
fold,
46+
in: context,
47+
using: layoutManager
48+
)
49+
}
50+
51+
context.restoreGState()
52+
}
53+
54+
private func getDrawingFolds(forTextRange textRange: Range<Int>) -> [FoldRange] {
4255
var folds = model?.getFolds(in: textRange) ?? []
56+
57+
// Add in some fake depths, we can draw these underneath the rest of the folds to make it look like it's
58+
// continuous
4359
if let minimumDepth = folds.min(by: { $0.depth < $1.depth })?.depth {
4460
for depth in (1..<minimumDepth).reversed() {
4561
folds.insert(
@@ -53,16 +69,8 @@ extension FoldingRibbonView {
5369
)
5470
}
5571
}
56-
for (idx, fold) in folds.enumerated() {
57-
drawFoldMarker(
58-
fold,
59-
isFirst: idx == 0,
60-
in: context,
61-
using: layoutManager
62-
)
63-
}
6472

65-
context.restoreGState()
73+
return folds
6674
}
6775

6876
/// Draw a single fold marker for a fold.
@@ -77,12 +85,11 @@ extension FoldingRibbonView {
7785
/// - layoutManager: A layout manager used to retrieve position information for lines.
7886
private func drawFoldMarker(
7987
_ fold: FoldRange,
80-
isFirst: Bool,
8188
in context: CGContext,
8289
using layoutManager: TextLayoutManager
8390
) {
8491
guard let minYPosition = layoutManager.textLineForOffset(fold.range.lowerBound)?.yPos,
85-
let maxPosition = layoutManager.textLineForOffset(fold.range.upperBound - 1) else {
92+
let maxPosition = layoutManager.textLineForOffset(fold.range.upperBound) else {
8693
return
8794
}
8895

@@ -101,7 +108,6 @@ extension FoldingRibbonView {
101108
} else {
102109
drawNestedFold(
103110
fold: fold,
104-
isFirst: isFirst,
105111
minYPosition: minYPosition,
106112
maxYPosition: maxYPosition,
107113
in: context
@@ -190,7 +196,6 @@ extension FoldingRibbonView {
190196

191197
private func drawNestedFold(
192198
fold: FoldRange,
193-
isFirst: Bool,
194199
minYPosition: CGFloat,
195200
maxYPosition: CGFloat,
196201
in context: CGContext
@@ -201,16 +206,8 @@ extension FoldingRibbonView {
201206
let roundedRect = NSBezierPath(roundedRect: plainRect, xRadius: 3.5, yRadius: 3.5)
202207

203208
context.setFillColor(markerColor)
204-
205-
// if isFirst {
206-
// for _ in 0..<fold.depth {
207-
// context.addPath(roundedRect.cgPathFallback)
208-
// context.drawPath(using: .fill)
209-
// }
210-
// } else {
211-
context.addPath(roundedRect.cgPathFallback)
212-
context.drawPath(using: .fill)
213-
// }
209+
context.addPath(roundedRect.cgPathFallback)
210+
context.drawPath(using: .fill)
214211

215212
// Add small white line if we're overlapping with other markers
216213
if fold.depth != 0 {
@@ -221,6 +218,7 @@ extension FoldingRibbonView {
221218
in: context
222219
)
223220
}
221+
224222
context.restoreGState()
225223
}
226224

0 commit comments

Comments
 (0)