Skip to content

Commit

Permalink
Fix panic when turn a skip
Browse files Browse the repository at this point in the history
  • Loading branch information
Piknik1990 committed Jun 12, 2024
1 parent d47240c commit 9d558e1
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 43 deletions.
18 changes: 0 additions & 18 deletions README-rus.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,3 @@ countdowndsm /path/to/config.yml
## Лицензия

[MIT](LICENSE)

## Известные баги

Если часто нажимать `Space` или `Enter` слишком часто (чаще, чем раз в кадр), то программа вытелает в ошибку с сообщением `out of range`

```
...
panic: runtime error: slice bounds out of range [:-1]
[running]:
github.com/nsf/termbox-go.PollEvent(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/home/nifaninks/go/pkg/mod/github.com/nsf/[email protected]/api.go:384 +0x93a
main.main.func2()
/share/git/countdowndsm/main.go:135 +0x30
created by main.main
/share/git/countdowndsm/main.go:133 +0xbd
```

На штатную работу приложения (если редко использовать пропуск) это не влияет.
18 changes: 0 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,3 @@ The configuration file contains the following parameters:
## License

[MIT](LICENSE)

## Known bugs

If you often press `Space` or `Enter` too often (more than once per frame), the program crashes into an error with the message `out of range`

```
...
panic: runtime error: slice bounds out of range [:-1]
[running]:
github.com/nsf/termbox-go.PollEvent(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/home/nifaninks/go/pkg/mod/github.com/nsf/[email protected]/api.go:384 +0x93a
main.main.func2()
/share/git/countdowndsm/main.go:135 +0x30
created by main.main
/share/git/countdowndsm/main.go:133 +0xbd
```

For regular operation of the application (if you rarely use a pass) it has no effect.
8 changes: 1 addition & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,8 @@ func countdown(totalDuration time.Duration, actTitle string, personNote string)

var (
exitCode int
skipAndContinue bool
)

skipAndContinue = false
w, h = termbox.Size()
start(timeLeft)

Expand All @@ -167,15 +165,11 @@ loop:
}
// Space/Enter
if ev.Key == termbox.KeySpace || ev.Key == termbox.KeyEnter {
skipAndContinue = true
break loop
}

case <-ticker.C:
timeLeft -= tick
if skipAndContinue == true {
skipAndContinue = false
break loop
}
draw(title, timeLeft, note, w, h)
case <-timer.C:
break loop
Expand Down

0 comments on commit 9d558e1

Please sign in to comment.