commit 1c5d730

delthas  ·  2022-06-04 07:20:49 +0000 UTC
parent 7a9fe74
Fix crashing on removing last char of backsearch pattern

To reproduce:
- Enter a message
- Enter a substring of that message, backsearch it
- Press backspace until the substring is cleared
- senpai crashes

This merely fixes the crash. We could do backsearch better in the future
but that's a whole feature overhaul to be done in its own patch.

Thanks to paren@disroot.org for helping me find the issue by sending a
panic trace :)
1 files changed,  +1, -1
+1, -1
1@@ -122,7 +122,7 @@ func (e *Editor) RemRune() (ok bool) {
2 	e.left()
3 	e.autoCache = nil
4 	if e.backsearch {
5-		if e.TextLen() == 0 {
6+		if e.TextLen() == 0 || len(e.backsearchPattern) == 0 {
7 			e.backsearchEnd()
8 		} else {
9 			e.backsearchPattern = e.backsearchPattern[:len(e.backsearchPattern)-1]