Skip to content

Commit

Permalink
修复末尾属性设置错误带来的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
rztime committed Jan 23, 2024
1 parent 0f15557 commit da0ed34
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion RZRichTextView/Classes/AttributedStringRich.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,22 @@ public extension RZRichTextBase where T : NSAttributedString {
let all = self.allParapraghRange()
var res: [NSRange] = []
for (idx, tempRange) in all.enumerated() {
if idx == all.count - 1 {
if let _ = range.intersection(tempRange) {
res.append(tempRange)
} else if idx == all.count - 1 {
if range.location >= tempRange.location && range.location <= tempRange.rt.maxLength() {
res.append(tempRange)
} else if range.upperBound >= tempRange.location && range.upperBound <= tempRange.upperBound {
res.append(tempRange)
}
} else if range.location >= tempRange.rt.maxLength() {

} else if range.location >= tempRange.location && range.location <= tempRange.rt.maxLength() {
res.append(tempRange)
} else if range.location < tempRange.location && range.rt.maxLength() > tempRange.location {
res.append(tempRange)
} else if range.upperBound >= tempRange.location && range.upperBound <= tempRange.upperBound {
res.append(tempRange)
}
}
return res
Expand Down
2 changes: 1 addition & 1 deletion RZRichTextView/Classes/RZRichTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ public extension RZRichTextView {
self.typingAttributes = self.lastTexttypingAttributes
}
}
self.lastCursorIsEnd = self.selectedRange.location == self.textStorage.length
self.lastCursorIsEnd = self.selectedRange.location == self.textStorage.length || self.selectedRange.upperBound == self.textStorage.length
}
/// 获取真实的属性
func getRealTypingAttributes() -> [NSAttributedString.Key: Any] {
Expand Down

0 comments on commit da0ed34

Please sign in to comment.