@@ -17,12 +17,12 @@ extension TextViewController {
1717 textView. editSelections { textView, selection in
1818 guard let lineIndexes = getOverlappingLines ( for: selection. range) else { return }
1919 let lowerBound = lineIndexes. lowerBound
20- guard
21- lowerBound > . zero ,
22- let prevLineInfo = textView. layoutManager . textLineForIndex ( lowerBound - 1 ) ,
23- let prevString = textView. textStorage . substring ( from : prevLineInfo . range ) ,
24- let lastSelectedString = textView . layoutManager . textLineForIndex ( lineIndexes . upperBound )
25- else { return }
20+ guard lowerBound > . zero ,
21+ let prevLineInfo = textView . layoutManager . textLineForIndex ( lowerBound - 1 ) ,
22+ let prevString = textView. textStorage . substring ( from : prevLineInfo . range ) ,
23+ let lastSelectedString = textView. layoutManager . textLineForIndex ( lineIndexes . upperBound ) else {
24+ return
25+ }
2626
2727 textView. insertString ( prevString, at: lastSelectedString. range. upperBound)
2828 textView. replaceCharacters ( in: [ prevLineInfo. range] , with: String ( ) )
@@ -48,12 +48,12 @@ extension TextViewController {
4848 guard let lineIndexes = getOverlappingLines ( for: selection. range) else { return }
4949 let totalLines = textView. layoutManager. lineCount
5050 let upperBound = lineIndexes. upperBound
51- guard
52- upperBound + 1 < totalLines ,
53- let nextLineInfo = textView. layoutManager . textLineForIndex ( upperBound + 1 ) ,
54- let nextString = textView. textStorage . substring ( from : nextLineInfo . range ) ,
55- let firstSelectedString = textView . layoutManager . textLineForIndex ( lineIndexes . lowerBound )
56- else { return }
51+ guard upperBound + 1 < totalLines ,
52+ let nextLineInfo = textView . layoutManager . textLineForIndex ( upperBound + 1 ) ,
53+ let nextString = textView. textStorage . substring ( from : nextLineInfo . range ) ,
54+ let firstSelectedString = textView. layoutManager . textLineForIndex ( lineIndexes . lowerBound ) else {
55+ return
56+ }
5757
5858 textView. replaceCharacters ( in: [ nextLineInfo. range] , with: String ( ) )
5959 textView. insertString ( nextString, at: firstSelectedString. range. lowerBound)
0 commit comments