Skip to content

Commit 85cf92d

Browse files
committed
FIx Infinite Loop When Zero-Width
1 parent 40e2a0f commit 85cf92d

File tree

4 files changed

+83
-5
lines changed

4 files changed

+83
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1620"
4+
version = "1.7">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES"
8+
buildArchitectures = "Automatic">
9+
<BuildActionEntries>
10+
<BuildActionEntry
11+
buildForTesting = "YES"
12+
buildForRunning = "YES"
13+
buildForProfiling = "YES"
14+
buildForArchiving = "YES"
15+
buildForAnalyzing = "YES">
16+
<BuildableReference
17+
BuildableIdentifier = "primary"
18+
BlueprintIdentifier = "6CCDA27C2D306A1B007CD84A"
19+
BuildableName = "CodeEditTextViewExample.app"
20+
BlueprintName = "CodeEditTextViewExample"
21+
ReferencedContainer = "container:CodeEditTextViewExample.xcodeproj">
22+
</BuildableReference>
23+
</BuildActionEntry>
24+
</BuildActionEntries>
25+
</BuildAction>
26+
<TestAction
27+
buildConfiguration = "Debug"
28+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
29+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
30+
shouldUseLaunchSchemeArgsEnv = "YES"
31+
shouldAutocreateTestPlan = "YES">
32+
</TestAction>
33+
<LaunchAction
34+
buildConfiguration = "Debug"
35+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
36+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
37+
launchStyle = "0"
38+
useCustomWorkingDirectory = "NO"
39+
ignoresPersistentStateOnLaunch = "NO"
40+
debugDocumentVersioning = "YES"
41+
debugServiceExtension = "internal"
42+
allowLocationSimulation = "YES">
43+
<BuildableProductRunnable
44+
runnableDebuggingMode = "0">
45+
<BuildableReference
46+
BuildableIdentifier = "primary"
47+
BlueprintIdentifier = "6CCDA27C2D306A1B007CD84A"
48+
BuildableName = "CodeEditTextViewExample.app"
49+
BlueprintName = "CodeEditTextViewExample"
50+
ReferencedContainer = "container:CodeEditTextViewExample.xcodeproj">
51+
</BuildableReference>
52+
</BuildableProductRunnable>
53+
</LaunchAction>
54+
<ProfileAction
55+
buildConfiguration = "Release"
56+
shouldUseLaunchSchemeArgsEnv = "YES"
57+
savedToolIdentifier = ""
58+
useCustomWorkingDirectory = "NO"
59+
debugDocumentVersioning = "YES">
60+
<BuildableProductRunnable
61+
runnableDebuggingMode = "0">
62+
<BuildableReference
63+
BuildableIdentifier = "primary"
64+
BlueprintIdentifier = "6CCDA27C2D306A1B007CD84A"
65+
BuildableName = "CodeEditTextViewExample.app"
66+
BlueprintName = "CodeEditTextViewExample"
67+
ReferencedContainer = "container:CodeEditTextViewExample.xcodeproj">
68+
</BuildableReference>
69+
</BuildableProductRunnable>
70+
</ProfileAction>
71+
<AnalyzeAction
72+
buildConfiguration = "Debug">
73+
</AnalyzeAction>
74+
<ArchiveAction
75+
buildConfiguration = "Release"
76+
revealArchiveInOrganizer = "YES">
77+
</ArchiveAction>
78+
</Scheme>

Sources/CodeEditTextView/TextLayoutManager/TextLayoutManager+Public.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ extension TextLayoutManager {
134134
point: CGPoint,
135135
inLine linePosition: TextLineStorage<TextLine>.TextLinePosition
136136
) -> Int? {
137-
guard let (content, contentPosition) = fragment.findContent(atX: point.x) else {
137+
guard let (content, contentPosition) = fragment.findContent(atX: point.x - edgeInsets.left) else {
138138
return nil
139139
}
140140
switch content.data {

Sources/CodeEditTextView/TextLine/LineFragment.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ public final class LineFragment: Identifiable, Equatable {
1717
case attachment(attachment: AnyTextAttachment)
1818
}
1919

20-
let data: Content
21-
let width: CGFloat
20+
public let data: Content
21+
public let width: CGFloat
2222

23-
var length: Int {
23+
public var length: Int {
2424
switch data {
2525
case .text(let line):
2626
CTLineGetStringRange(line).length

Sources/CodeEditTextView/TextLine/Typesetter/Typesetter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ final public class Typesetter {
4444
lineFragments.removeAll()
4545

4646
// Fast path
47-
if string.length == 0 {
47+
if string.length == 0 || displayData.maxWidth <= 0 {
4848
typesetEmptyLine(displayData: displayData, string: string)
4949
return
5050
}

0 commit comments

Comments
 (0)