mirror of https://github.com/Hilbis/Hilbish
fix: hilbish.read overriding history
parent
764e2372a2
commit
4ef6c7d5c0
2
api.go
2
api.go
|
@ -206,7 +206,7 @@ func getenv(key, fallback string) string {
|
|||
// --- @param prompt string
|
||||
func hlread(L *lua.LState) int {
|
||||
luaprompt := L.CheckString(1)
|
||||
lualr := newLineReader("")
|
||||
lualr := newLineReader("", true)
|
||||
lualr.SetPrompt(luaprompt)
|
||||
|
||||
input, err := lualr.Read()
|
||||
|
|
2
main.go
2
main.go
|
@ -114,7 +114,7 @@ func main() {
|
|||
|
||||
go handleSignals()
|
||||
luaInit()
|
||||
lr = newLineReader("")
|
||||
lr = newLineReader("", false)
|
||||
// If user's config doesn't exixt,
|
||||
if _, err := os.Stat(defaultConfPath); os.IsNotExist(err) && *configflag == defaultConfPath {
|
||||
// Read default from current directory
|
||||
|
|
6
rl.go
6
rl.go
|
@ -15,8 +15,11 @@ type lineReader struct {
|
|||
var fileHist *fileHistory
|
||||
|
||||
// other gophers might hate this naming but this is local, shut up
|
||||
func newLineReader(prompt string) *lineReader {
|
||||
func newLineReader(prompt string, noHist bool) *lineReader {
|
||||
rl := readline.NewInstance()
|
||||
// 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 {
|
||||
|
@ -24,6 +27,7 @@ func newLineReader(prompt string) *lineReader {
|
|||
}
|
||||
rl.SetHistoryCtrlR("file", fileHist)
|
||||
rl.HistoryAutoWrite = false
|
||||
}
|
||||
rl.ShowVimMode = false
|
||||
rl.ViModeCallback = func(mode readline.ViMode) {
|
||||
modeStr := ""
|
||||
|
|
Loading…
Reference in New Issue