mirror of
https://github.com/makew0rld/amfora.git
synced 2025-02-02 15:07:34 -05:00
🐛 Use recover() on WordWrap - fixes #20
This commit is contained in:
parent
293a1a1db0
commit
5bb62f7a80
@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
### Fixed
|
||||
- Actual unicode bullet symbol is used for lists: U+2022
|
||||
- Performance when loading very long cached pages improved (#26)
|
||||
- Doesn't crash when wrapping certain complex lines (#20)
|
||||
|
||||
## [1.1.0] - 2020-06-24
|
||||
### Added
|
||||
|
5
NOTES.md
5
NOTES.md
@ -4,8 +4,11 @@
|
||||
- And then just one single map of tab number to `tab`
|
||||
|
||||
## Bugs
|
||||
- Wrapping is messed up on CHAZ post, but nothing else
|
||||
- Wrapping messes up on brackets
|
||||
- Filed [issue 23](https://gitlab.com/tslocum/cview/-/issues/23)
|
||||
- Wrapping panics on strings with brackets and Asian characters
|
||||
- Filed cview [issue 27](https://gitlab.com/tslocum/cview/-/issues/27)
|
||||
- The panicking was reported and fixed in Amfora [issue 20](https://github.com/makeworld-the-better-one/amfora/issues/20), but the lines are now just not wrapped
|
||||
- Text background not reset on ANSI pages
|
||||
- Filed [issue 25](https://gitlab.com/tslocum/cview/-/issues/25)
|
||||
- Modal styling messed up when wrapped - example occurence is the error modal for a long unsupported scheme URL
|
||||
|
@ -124,13 +124,33 @@ func convertRegularGemini(s string, numLinks int, width int) (string, []string)
|
||||
lines[i] = strings.TrimPrefix(lines[i], ">")
|
||||
lines[i] = strings.TrimPrefix(lines[i], " ")
|
||||
|
||||
temp := cview.WordWrap(lines[i], width)
|
||||
for i := range temp {
|
||||
temp[i] = "> " + temp[i]
|
||||
}
|
||||
wrappedLines = append(wrappedLines, temp...)
|
||||
// Anonymous function to allow recovery from potential WordWrap panic
|
||||
func() {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
// Add unwrapped line instead
|
||||
wrappedLines = append(wrappedLines, "> "+lines[i])
|
||||
}
|
||||
}()
|
||||
|
||||
temp := cview.WordWrap(lines[i], width)
|
||||
for i := range temp {
|
||||
temp[i] = "> " + temp[i]
|
||||
}
|
||||
wrappedLines = append(wrappedLines, temp...)
|
||||
}()
|
||||
} else {
|
||||
wrappedLines = append(wrappedLines, cview.WordWrap(lines[i], width)...)
|
||||
// Anonymous function to allow recovery from potential WordWrap panic
|
||||
func() {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
// Add unwrapped line instead
|
||||
wrappedLines = append(wrappedLines, lines[i])
|
||||
}
|
||||
}()
|
||||
|
||||
wrappedLines = append(wrappedLines, cview.WordWrap(lines[i], width)...)
|
||||
}()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user