Skip to content

Commit 2be0c99

Browse files
committed
Fixed: pattern(_:) where capacity == 0 such that hidden(_:) also works.
1 parent b652e27 commit 2be0c99

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

Sources/DiffableTextKitXPattern/Style.swift

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,7 @@ extension PatternTextStyle {
117117
} none: {
118118
commit, virtuals in
119119
commit.snapshot.append(contentsOf: virtuals, as: .phantom)
120-
//=----------------------------------=
121-
// Selection
122-
//=----------------------------------=
123-
switch virtuals.endIndex != pattern.endIndex { // real vs fake
124-
case true: commit.snapshot.select(commit.snapshot .endIndex)
125-
case false: commit.snapshot.select(commit.snapshot.startIndex) }
120+
commit.snapshot.select(commit.snapshot.endIndex)
126121
} done: {
127122
commit, virtuals, mismatches in
128123
//=----------------------------------=
@@ -231,8 +226,18 @@ extension PatternTextStyle {
231226
// (!) None
232227
//=--------------------------------------=
233228
if pIndex == pattern.startIndex {
234-
none(&result, pattern[pIndex ..< qIndex])
235-
pIndex = qIndex
229+
//=----------------------------------=
230+
// Placeholders == 0
231+
//=----------------------------------=
232+
if qIndex == pattern.endIndex {
233+
none(&result, pattern[pIndex ..< pIndex])
234+
//=----------------------------------=
235+
// Placeholder >= 1
236+
//=----------------------------------=
237+
} else {
238+
none(&result, pattern[pIndex ..< qIndex])
239+
pIndex = qIndex
240+
}
236241
}
237242
//=--------------------------------------=
238243
// (!) Done

0 commit comments

Comments
 (0)