commit b6e7fbf

delthas  ·  2021-07-14 20:33:17 +0000 UTC
parent 5109024
Fix crash on disconnect

The crash was due to accessing app.s.Nick() when app.s was nil.

This is a good opportunity to print a special prompt when disconnected:
I chose `<offline>`, in red.
1 files changed,  +6, -0
M app.go
M app.go
+6, -0
 1@@ -811,6 +811,12 @@ func (app *App) updatePrompt() {
 2 				StyleDefault.
 3 				Foreground(tcell.Color(app.cfg.Colors.Prompt)),
 4 		)
 5+	} else if app.s == nil {
 6+		prompt = ui.Styled("<offline>",
 7+			tcell.
 8+				StyleDefault.
 9+				Foreground(tcell.ColorRed),
10+		)
11 	} else {
12 		prompt = identString(app.s.Nick())
13 	}