Skip to content

Commit

Permalink
Fix iOS textview reference, update SwiftTreeSitter, remove compat target
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmassicotte committed Nov 25, 2024
1 parent 94b004a commit 07a3254
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 61 deletions.
3 changes: 2 additions & 1 deletion Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/ChimeHQ/SwiftTreeSitter",
"state" : {
"revision" : "f01316eaf3aae07e30478f8afa76192ab4a96420"
"revision" : "36aa61d1b531f744f35229f010efba9c6d6cbbdd",
"version" : "0.9.0"
}
},
{
Expand Down
7 changes: 2 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@ let package = Package(
.library(name: "Neon", targets: ["Neon"]),
],
dependencies: [
.package(url: "https://github.com/ChimeHQ/SwiftTreeSitter", revision: "f01316eaf3aae07e30478f8afa76192ab4a96420"),
.package(url: "https://github.com/ChimeHQ/SwiftTreeSitter", from: "0.9.0"),
.package(url: "https://github.com/ChimeHQ/Rearrange", from: "1.8.1"),
],
targets: [
.target(name: "ConcurrencyCompatibility"),
.target(name: "RangeState", dependencies: ["ConcurrencyCompatibility", "Rearrange"]),
.target(name: "RangeState", dependencies: ["Rearrange"]),
.testTarget(name: "RangeStateTests", dependencies: ["RangeState"]),
.target(
name: "Neon",
dependencies: [
"ConcurrencyCompatibility",
"RangeState",
"Rearrange",
"TreeSitterClient",
Expand All @@ -35,7 +33,6 @@ let package = Package(
.target(
name: "TreeSitterClient",
dependencies: [
"ConcurrencyCompatibility",
"RangeState",
"Rearrange",
"SwiftTreeSitter",
Expand Down
46 changes: 0 additions & 46 deletions Sources/ConcurrencyCompatibility/Compatibility.swift

This file was deleted.

6 changes: 2 additions & 4 deletions Sources/Neon/TextViewHighlighter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,7 @@ public final class TextViewHighlighter {

try textView.getTextStorage().delegate = storageDelegate

if textView.enclosingScrollView != nil {
observeEnclosingScrollView()
}
observeEnclosingScrollView()

invalidate(.all)
}
Expand Down Expand Up @@ -175,7 +173,7 @@ extension TextViewHighlighter {
)
#elseif os(iOS) || os(visionOS)
self.frameObservation = textView.observe(\.contentOffset) { [weak self] view, _ in
MainActor.backport.assumeIsolated {
MainActor.assumeIsolated {
guard let self = self else { return }

self.lastVisibleRange = self.textView.visibleTextRange
Expand Down
1 change: 0 additions & 1 deletion Sources/RangeState/RangeProcessor.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Foundation

import ConcurrencyCompatibility
import Rearrange

public enum RangeFillMode: Sendable, Hashable {
Expand Down
1 change: 0 additions & 1 deletion Sources/RangeState/RangeValidator.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Foundation

import ConcurrencyCompatibility
import Rearrange

public enum Validation: Sendable, Hashable {
Expand Down
1 change: 0 additions & 1 deletion Sources/RangeState/SinglePhaseRangeValidator.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Foundation

import ConcurrencyCompatibility
import Rearrange

@MainActor
Expand Down
1 change: 0 additions & 1 deletion Sources/RangeState/ThreePhaseRangeValidator.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Foundation

import ConcurrencyCompatibility
import Rearrange

@MainActor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Foundation

import ConcurrencyCompatibility
import SwiftTreeSitter
import SwiftTreeSitterLayer

Expand Down
21 changes: 21 additions & 0 deletions Sources/TreeSitterClient/DispatchQueueBackport.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Foundation

struct DispatchQueueBackport {
private let queue: DispatchQueue

init(_ queue: DispatchQueue) {
self.queue = queue
}

func asyncUnsafe(group: DispatchGroup? = nil, qos: DispatchQoS = .unspecified, flags: DispatchWorkItemFlags = [], execute unsafeWork: @escaping @convention(block) () -> Void) {
let work = unsafeBitCast(unsafeWork, to: (@Sendable @convention(block) () -> Void).self)

queue.async(group: group, qos: qos, flags: flags, execute: work)
}
}

extension DispatchQueue {
var backport: DispatchQueueBackport {
DispatchQueueBackport(self)
}
}

0 comments on commit 07a3254

Please sign in to comment.