mirror of
https://github.com/charmbracelet/gum
synced 2024-05-10 02:06:36 +02:00
removed bksp from stdin (#306)
* removed bksp from stdin --------- Co-authored-by: Maas Lalani <maas@lalani.dev>
This commit is contained in:
parent
ccc5d9cfea
commit
ec2b8d0fee
|
@ -2,6 +2,7 @@ package pager
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"regexp"
|
||||||
|
|
||||||
"github.com/alecthomas/kong"
|
"github.com/alecthomas/kong"
|
||||||
"github.com/charmbracelet/bubbles/viewport"
|
"github.com/charmbracelet/bubbles/viewport"
|
||||||
|
@ -22,7 +23,9 @@ func (o Options) Run() error {
|
||||||
return fmt.Errorf("unable to read stdin")
|
return fmt.Errorf("unable to read stdin")
|
||||||
}
|
}
|
||||||
if stdin != "" {
|
if stdin != "" {
|
||||||
o.Content = stdin
|
// Sanitize the input from stdin by removing backspace sequences.
|
||||||
|
backspace := regexp.MustCompile(".\x08")
|
||||||
|
o.Content = backspace.ReplaceAllString(stdin, "")
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("provide some content to display")
|
return fmt.Errorf("provide some content to display")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue