2
2
espelhamento de https://github.com/Hilbis/Hilbish sincronizado 2025-07-10 21:12:02 +00:00

refactor: panic in history.go for more context

Esse commit está contido em:
TorchedSammy 2022-03-12 21:43:02 -04:00
commit 0e4f552be2
Assinado por: sammyette
ID da chave GPG: 904FC49417B44DCD
2 arquivos alterados com 5 adições e 9 exclusões

Ver arquivo

@ -12,11 +12,11 @@ type fileHistory struct {
f *os.File
}
func newFileHistory() (*fileHistory, error) {
func newFileHistory() *fileHistory {
data, err := os.ReadFile(defaultHistPath)
if err != nil {
if !errors.Is(err, fs.ErrNotExist) {
return nil, err
panic(err)
}
}
@ -30,7 +30,7 @@ func newFileHistory() (*fileHistory, error) {
}
f, err := os.OpenFile(defaultHistPath, os.O_APPEND | os.O_WRONLY | os.O_CREATE, 0755)
if err != nil {
return nil, err
panic(err)
}
fh := &fileHistory{
@ -38,7 +38,7 @@ func newFileHistory() (*fileHistory, error) {
f: f,
}
return fh, nil
return fh
}
func (h *fileHistory) Write(line string) (int, error) {

6
rl.go
Ver arquivo

@ -20,11 +20,7 @@ func newLineReader(prompt string, noHist bool) *lineReader {
// we don't mind hilbish.read rl instances having completion,
// but it cant have shared history
if !noHist {
fh, err := newFileHistory()
fileHist = fh // go stupid
if err != nil {
panic(err)
}
fileHist = newFileHistory()
rl.SetHistoryCtrlR("file", fileHist)
rl.HistoryAutoWrite = false
}