File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -1803,8 +1803,26 @@ extension MainViewController {
18031803 if word. count > maxLineLength {
18041804 var wordToProcess = word
18051805 while !wordToProcess. isEmpty {
1806- let availableSpace = maxLineLength - ( currentLine. isEmpty ? 0 : currentLine. count + 1 )
1806+ let spaceCount = currentLine. isEmpty ? 0 : 1
1807+ let availableSpace = maxLineLength - ( currentLine. count + spaceCount)
1808+
1809+ if availableSpace <= 0 {
1810+ if !currentLine. isEmpty {
1811+ lines. append ( currentLine)
1812+ currentLine = " "
1813+ }
1814+ continue
1815+ }
1816+
18071817 let takeCount = min ( wordToProcess. count, availableSpace)
1818+ if takeCount <= 0 {
1819+ if !currentLine. isEmpty {
1820+ lines. append ( currentLine)
1821+ currentLine = " "
1822+ }
1823+ continue
1824+ }
1825+
18081826 let index = wordToProcess. index ( wordToProcess. startIndex, offsetBy: takeCount)
18091827 let substring = wordToProcess [ ..< index]
18101828
You can’t perform that action at this time.
0 commit comments