Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,31 @@ class StyledRangeContainer {
}
}

enum RunState {
case empty
case value(RangeStoreRun<StyleElement>)
case exhausted

var isExhausted: Bool {
if case .exhausted = self { return true }
return false
}

var hasValue: Bool {
if case .value = self { return true }
return false
}

var length: Int {
switch self {
case .empty, .exhausted:
return 0
case .value(let run):
return run.length
}
}
}

var _storage: [ProviderID: RangeStore<StyleElement>] = [:]
weak var delegate: StyledRangeContainerDelegate?

Expand Down Expand Up @@ -118,7 +143,9 @@ class StyledRangeContainer {
}
}

allRuns[minRunIdx].removeLast()
if !allRuns[minRunIdx].isEmpty {
allRuns[minRunIdx].removeLast()
}

runs.append(minRun)
minValue = allRuns.compactMap { $0.last }.enumerated().min(by: { $0.1.length < $1.1.length })
Expand Down
3 changes: 2 additions & 1 deletion Sources/CodeEditSourceEditor/SourceEditor/SourceEditor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ public struct SourceEditor: NSViewControllerRepresentable {
controller.setCursorPositions(cursorPositions)
}

if let scrollPosition = state.scrollPosition, scrollPosition != state.scrollPosition {
let scrollView = controller.scrollView
if let scrollPosition = state.scrollPosition, scrollPosition != scrollView?.contentView.bounds.origin {
controller.scrollView.scroll(controller.scrollView.contentView, to: scrollPosition)
controller.scrollView.reflectScrolledClipView(controller.scrollView.contentView)
controller.gutterView.needsDisplay = true
Expand Down