Skip to content

Commit eb16ab6

Browse files
committed
Enhance list handling in STMarkdownStreamingTransforms
- Updated logic to consider both unordered and ordered lists when determining nested indentation and stripping conditions. - Improved clarity by renaming variables for better understanding of their purpose in the context of list processing.
1 parent 81be858 commit eb16ab6

2 files changed

Lines changed: 6 additions & 9 deletions

File tree

‎Sources/STMarkdown/Parsing/STMarkdownStreamingTransforms.swift‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,9 @@ public enum STMarkdownStreamingTransforms {
155155
if lastWasStripped {
156156
shouldKeepNestedIndent = currentIndent > previousIndent
157157
} else {
158-
let previousIsUnordered = matches(Self.streamingAnyUnorderedListRegex, in: lastNonEmptyLine)
159-
shouldKeepNestedIndent = previousIsUnordered && currentIndent >= previousIndent
158+
let previousIsList = matches(Self.streamingAnyUnorderedListRegex, in: lastNonEmptyLine)
159+
|| matches(Self.streamingAnyListRegex, in: lastNonEmptyLine)
160+
shouldKeepNestedIndent = previousIsList && currentIndent >= previousIndent
160161
}
161162
if !shouldKeepNestedIndent {
162163
lines[index] = String(rawLine.drop { $0 == " " || $0 == "\t" })
@@ -171,8 +172,9 @@ public enum STMarkdownStreamingTransforms {
171172
if lastWasStripped {
172173
shouldStrip = currentIndent <= previousIndent
173174
} else {
174-
let previousIsUnordered = matches(Self.streamingAnyUnorderedListRegex, in: lastNonEmptyLine)
175-
shouldStrip = !previousIsUnordered
175+
let previousIsList = matches(Self.streamingAnyUnorderedListRegex, in: lastNonEmptyLine)
176+
|| matches(Self.streamingAnyListRegex, in: lastNonEmptyLine)
177+
shouldStrip = !previousIsList
176178
}
177179
if shouldStrip {
178180
lines[index] = String(rawLine.drop { $0 == " " || $0 == "\t" })

‎Sources/STMarkdown/UI/STMarkdownStreamingTextView.swift‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -652,11 +652,6 @@ public final class STMarkdownStreamingTextView: STMarkdownBaseTextView {
652652
at: cursor,
653653
effectiveRange: &blockRange
654654
)
655-
// No blockID attribute at all: custom renderer without STMarkdown metadata.
656-
// Fall back to treating the entire delta as inlineProgressive.
657-
guard rawBlockIDValue != nil else {
658-
return NSRange(location: 0, length: attributedText.length)
659-
}
660655
guard let blockID = rawBlockIDValue as? String,
661656
blockID.isEmpty == false else {
662657
return nil

0 commit comments

Comments
 (0)