Skip to content

Commit

Permalink
Initial fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikBucher12 committed Jan 24, 2024
1 parent 37e5a1b commit 4e91801
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public extension RichTextViewComponent {
_ alignment: RichTextAlignment
) {
if richTextAlignment == alignment { return }
if !hasTrimmedText {
if !hasTrimmedText || !hasSelectedRange {
let style = NSMutableParagraphStyle()
style.alignment = alignment.nativeAlignment
var attributes = richTextAttributes
Expand Down
4 changes: 2 additions & 2 deletions Sources/RichTextKit/Extensions/String+Paragraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public extension String {
after the newline char, not the newline itself.
*/

func findIndexOfNextParagraphOrEndofCurrent(from location: UInt) -> UInt {
func findIndexOfNextParagraphOrEndOfCurrent(from location: UInt) -> UInt {
var index = location
repeat {
guard let char = character(at: index) else { break }
Expand All @@ -80,7 +80,7 @@ public extension String {
func findLengthOfCurrentParagraph(from location: UInt) -> Int {
if isEmpty { return 0 }
let startIndex = findIndexOfCurrentParagraph(from: location)
let endIndex = findIndexOfNextParagraphOrEndofCurrent(from: location)
let endIndex = findIndexOfNextParagraphOrEndOfCurrent(from: location)
return Int(endIndex)-Int(startIndex)
}

Expand Down

0 comments on commit 4e91801

Please sign in to comment.