You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Extra newlines when combining unconditional and standard word wrapping #43
When combining word-wrapping with unconditional wrapping as described in the README, extra linebreaks can sometimes be found in the output.
For example:
conststr="the quick brown foxxxxxxxxxxxxxxxx jumped over the lazy dog."constlimit=16wrapped:=wrap.String(wordwrap.String(str, limit), limit)
fmt.Println(wrapped)
Outputs:
the quick brown
foxxxxxxxxxxxxxx
xx
jumped over the
lazy dog.
However, I'd expect it to be:
the quick brown
foxxxxxxxxxxxxxx
xx jumped over
the lazy dog.
I'm also running into this issue. I may be able to take a stab at implementing what @bashbunni is describing if she isn't doing so already.
Depending on what you actually need, you can also just initialize a new wrap.Writer and set PreserveNewlines to false.
By setting wrap.Wrap.PreserveNewlines to false, won't this cause wrap.Wrap to undo the work which wordwrap.Wrap did? wordwrap.Wrap is only adding newlines to the string. If we don't preserve them it will be as if wordwrap.Wrap never modified the original string, right?
OK, I took a stab at adding this feature the library but ran into some problems while trying to maintain the current functionality. To better wrap my head around the problem, I implemented the wrapping functionality I need in my own project. I'm still open to porting this functionality back into this project if it's something the author wants.
Activity
test: add wordwrapping tests for issue muesli#43
bashbunni commentedon Sep 14, 2023
We could probably enhance wordwrap to include forceful newlines to break words at the given width. The wrapper is behaving as expected in this case. (New lines are preserved by default)
https://github.com/bashbunni/reflow/blob/master/wrap/wrap.go#L36
janderland commentedon Sep 17, 2023
I'm also running into this issue. I may be able to take a stab at implementing what @bashbunni is describing if she isn't doing so already.
muesli commentedon Sep 18, 2023
Depending on what you actually need, you can also just initialize a new
wrap.Writerand setPreserveNewlinestofalse.janderland commentedon Sep 18, 2023
By setting
wrap.Wrap.PreserveNewlinestofalse, won't this causewrap.Wrapto undo the work whichwordwrap.Wrapdid?wordwrap.Wrapis only adding newlines to the string. If we don't preserve them it will be as ifwordwrap.Wrapnever modified the original string, right?janderland commentedon Nov 5, 2023
OK, I took a stab at adding this feature the library but ran into some problems while trying to maintain the current functionality. To better wrap my head around the problem, I implemented the wrapping functionality I need in my own project. I'm still open to porting this functionality back into this project if it's something the author wants.
fix: combining both conditional and unconditional wrapping
fix: combining both conditional and unconditional wrapping
fix: combining both conditional and unconditional wrapping
fix: combining both conditional and unconditional wrapping
fix: combining both conditional and unconditional wrapping
fix: combining both conditional and unconditional wrapping
fix: combining both conditional and unconditional wrapping
feat(term): ansi: add SmartWrap
feat(term): ansi: add SmartWrap
feat(term): ansi: add SmartWrap
fix: combining both conditional and unconditional wrapping
feat(term): ansi: add SmartWrap
fix: combining both conditional and unconditional wrapping
feat(term): ansi: add SmartWrap
feat(term): ansi: add SmartWrap
fix: combining both conditional and unconditional wrapping
fix: combining both conditional and unconditional wrapping
feat(term): ansi: move Wrap to Hardwrap and introduce Wrap (#57)
fix: combining both conditional and unconditional wrapping (#275)