Fixed prompt input to filter out 0x0D and 0x08 keystrokes

These can occur when pasting input with line-feeds.
This commit is contained in:
Leon Mika 2022-07-18 20:36:31 +10:00
parent 46a430f58f
commit 7b194d0a19
2 changed files with 17 additions and 3 deletions

View file

@ -7,3 +7,13 @@ func Map[T, U any](ts []T, fn func(t T) U) []U {
}
return us
}
func Filter[T any](ts []T, fn func(t T) bool) []T {
us := make([]T, 0)
for _, t := range ts {
if fn(t) {
us = append(us, t)
}
}
return us
}