mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-06 04:57:49 +00:00
FIXUP: Removed +1 causing substr slicing to skip chars on first iteration of while loop (#7312)
This commit is contained in:
committed by
Andreas Rumpf
parent
551d7b7dc1
commit
67fd7a7f86
@@ -1250,7 +1250,7 @@ proc wordWrap*(s: string, maxLineWidth = 80,
|
||||
if len(word) > spaceLeft:
|
||||
if splitLongWords and len(word) > maxLineWidth:
|
||||
result.add(substr(word, 0, spaceLeft-1))
|
||||
var w = spaceLeft+1
|
||||
var w = spaceLeft
|
||||
var wordLeft = len(word) - spaceLeft
|
||||
while wordLeft > 0:
|
||||
result.add(newLine)
|
||||
@@ -2514,6 +2514,11 @@ when isMainModule:
|
||||
outp = " this is a\nlong text\n--\nmuchlongerthan10chars\nand here\nit goes"
|
||||
doAssert wordWrap(inp, 10, false) == outp
|
||||
|
||||
let
|
||||
longInp = """ThisIsOneVeryLongStringWhichWeWillSplitIntoEightSeparatePartsNow"""
|
||||
longOutp = "ThisIsOn\neVeryLon\ngStringW\nhichWeWi\nllSplitI\nntoEight\nSeparate\nPartsNow"
|
||||
doAssert wordWrap(longInp, 8, true) == longOutp
|
||||
|
||||
doAssert formatBiggestFloat(1234.567, ffDecimal, -1) == "1234.567000"
|
||||
doAssert formatBiggestFloat(1234.567, ffDecimal, 0) == "1235."
|
||||
doAssert formatBiggestFloat(1234.567, ffDecimal, 1) == "1234.6"
|
||||
|
||||
Reference in New Issue
Block a user