mirror of
https://github.com/makew0rld/amfora.git
synced 2024-09-27 23:05:55 -04: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
|
### Fixed
|
||||||
- Actual unicode bullet symbol is used for lists: U+2022
|
- Actual unicode bullet symbol is used for lists: U+2022
|
||||||
- Performance when loading very long cached pages improved (#26)
|
- Performance when loading very long cached pages improved (#26)
|
||||||
|
- Doesn't crash when wrapping certain complex lines (#20)
|
||||||
|
|
||||||
## [1.1.0] - 2020-06-24
|
## [1.1.0] - 2020-06-24
|
||||||
### Added
|
### Added
|
||||||
|
5
NOTES.md
5
NOTES.md
@ -4,8 +4,11 @@
|
|||||||
- And then just one single map of tab number to `tab`
|
- And then just one single map of tab number to `tab`
|
||||||
|
|
||||||
## Bugs
|
## 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)
|
- 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
|
- Text background not reset on ANSI pages
|
||||||
- Filed [issue 25](https://gitlab.com/tslocum/cview/-/issues/25)
|
- 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
|
- 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], ">")
|
||||||
lines[i] = strings.TrimPrefix(lines[i], " ")
|
lines[i] = strings.TrimPrefix(lines[i], " ")
|
||||||
|
|
||||||
|
// 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)
|
temp := cview.WordWrap(lines[i], width)
|
||||||
for i := range temp {
|
for i := range temp {
|
||||||
temp[i] = "> " + temp[i]
|
temp[i] = "> " + temp[i]
|
||||||
}
|
}
|
||||||
wrappedLines = append(wrappedLines, temp...)
|
wrappedLines = append(wrappedLines, temp...)
|
||||||
|
}()
|
||||||
} else {
|
} else {
|
||||||
|
// 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)...)
|
wrappedLines = append(wrappedLines, cview.WordWrap(lines[i], width)...)
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user