Skip to content

Commit 0b840f6

Browse files
committed
Remove Some Unnecessary Hovering Stuff
1 parent c056e4a commit 0b840f6

2 files changed

Lines changed: 12 additions & 20 deletions

File tree

Sources/CodeEditSourceEditor/Gutter/LineFolding/FoldingRibbonView.swift

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -82,25 +82,18 @@ class FoldingRibbonView: NSView {
8282
hoveringLine = model.textView?.layoutManager.textLineForPosition(pointInView.y)?.index
8383
}
8484

85+
/// The context in which the fold is being drawn, including the depth and fold range.
8586
struct FoldMarkerDrawingContext {
8687
let range: ClosedRange<Int>
8788
let depth: UInt
88-
let hoveringLine: Int?
8989

90-
func increment() -> FoldMarkerDrawingContext {
90+
/// Increment the depth
91+
func incrementDepth() -> FoldMarkerDrawingContext {
9192
FoldMarkerDrawingContext(
9293
range: range,
93-
depth: depth + 1,
94-
hoveringLine: isHovering() ? nil : hoveringLine
94+
depth: depth + 1
9595
)
9696
}
97-
98-
func isHovering() -> Bool {
99-
guard let hoveringLine else {
100-
return false
101-
}
102-
return range.contains(hoveringLine)
103-
}
10497
}
10598

10699
override func draw(_ dirtyRect: NSRect) {
@@ -124,7 +117,7 @@ class FoldingRibbonView: NSView {
124117
for fold in folds {
125118
drawFoldMarker(
126119
fold,
127-
markerContext: FoldMarkerDrawingContext(range: lineRange, depth: 0, hoveringLine: hoveringLine),
120+
markerContext: FoldMarkerDrawingContext(range: lineRange, depth: 0),
128121
in: context,
129122
using: layoutManager
130123
)
@@ -156,12 +149,11 @@ class FoldingRibbonView: NSView {
156149

157150
let maxYPosition = maxPosition.yPos + maxPosition.height
158151

159-
// TODO: Draw a single line when folds are adjacent
160-
161-
if markerContext.isHovering() {
152+
if false /*model.getCachedDepthAt(lineNumber: hoveringLine ?? -1)*/ {
162153
// TODO: Handle hover state
163154
} else {
164155
let plainRect = NSRect(x: 0, y: minYPosition + 1, width: 7, height: maxYPosition - minYPosition - 2)
156+
// TODO: Draw a single horizontal line when folds are adjacent
165157
let roundedRect = NSBezierPath(roundedRect: plainRect, xRadius: 3.5, yRadius: 3.5)
166158

167159
context.addPath(roundedRect.cgPathFallback)
@@ -180,7 +172,7 @@ class FoldingRibbonView: NSView {
180172

181173
// Draw subfolds
182174
for subFold in fold.subFolds.filter({ $0.lineRange.overlaps(markerContext.range) }) {
183-
drawFoldMarker(subFold, markerContext: markerContext.increment(), in: context, using: layoutManager)
175+
drawFoldMarker(subFold, markerContext: markerContext.incrementDepth(), in: context, using: layoutManager)
184176
}
185177
}
186178

Sources/CodeEditSourceEditor/Gutter/LineFolding/LineFoldingModel.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,18 @@ class LineFoldingModel: NSObject, NSTextStorageDelegate {
104104
}
105105
invalidateLine(lineNumber: lineNumber)
106106
}
107-
}
108-
109-
// MARK: - Search Folds
110107

111-
private extension LineFoldingModel {
112108
/// Finds the deepest cached depth of the fold for a line number.
113109
/// - Parameter lineNumber: The line number to query, zero-indexed.
114110
/// - Returns: The deepest cached depth of the fold if it was found.
115111
func getCachedDepthAt(lineNumber: Int) -> Int? {
116112
return findCachedFoldAt(lineNumber: lineNumber)?.depth
117113
}
114+
}
115+
116+
// MARK: - Search Folds
118117

118+
private extension LineFoldingModel {
119119
/// Finds the deepest cached fold and depth of the fold for a line number.
120120
/// - Parameter lineNumber: The line number to query, zero-indexed.
121121
/// - Returns: The deepest cached fold and depth of the fold if it was found.

0 commit comments

Comments
 (0)