Skip to content

Commit

Permalink
Don't log unexpected exits
Browse files Browse the repository at this point in the history
Before this change, if we crashed inside either of these main loops, we
would still log messages about exiting the loops. Even if the reason for
exiting was a panic().

With this change in place, we only log expected exits. The idea is that
this should make it easier to understand where the crash was.
  • Loading branch information
walles committed Jan 1, 2025
1 parent 701bbb8 commit dcc9e24
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
1 change: 0 additions & 1 deletion m/pager.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ func (p *Pager) handleScrolledDown() {
// StartPaging brings up the pager on screen
func (p *Pager) StartPaging(screen twin.Screen, chromaStyle *chroma.Style, chromaFormatter *chroma.Formatter) {
log.Info("Pager starting")
defer log.Info("Pager done")

defer func() {
if p.reader.err != nil {
Expand Down
4 changes: 2 additions & 2 deletions twin/screen.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,15 +387,15 @@ func (screen *UnixScreen) ShowCursorAt(column int, row int) {
}

func (screen *UnixScreen) mainLoop() {
defer log.Info("Twin screen main loop done")

// "1400" comes from me trying fling scroll operations on my MacBook
// trackpad and looking at the high watermark (logged below).
//
// The highest I saw when I tried this was 700 something. 1400 is twice
// that, so 1400 should be good.
buffer := make([]byte, 1400)

log.Info("Entering Twin main loop...")

maxBytesRead := 0
expectingTerminalBackgroundColor := true
for {
Expand Down

0 comments on commit dcc9e24

Please sign in to comment.