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
|
// --- @param prompt string
|
||||||
func hlread(L *lua.LState) int {
|
func hlread(L *lua.LState) int {
|
||||||
luaprompt := L.CheckString(1)
|
luaprompt := L.CheckString(1)
|
||||||
lualr := newLineReader("")
|
lualr := newLineReader("", true)
|
||||||
lualr.SetPrompt(luaprompt)
|
lualr.SetPrompt(luaprompt)
|
||||||
|
|
||||||
input, err := lualr.Read()
|
input, err := lualr.Read()
|
||||||
|
|
2
main.go
2
main.go
|
@ -114,7 +114,7 @@ func main() {
|
||||||
|
|
||||||
go handleSignals()
|
go handleSignals()
|
||||||
luaInit()
|
luaInit()
|
||||||
lr = newLineReader("")
|
lr = newLineReader("", false)
|
||||||
// If user's config doesn't exixt,
|
// If user's config doesn't exixt,
|
||||||
if _, err := os.Stat(defaultConfPath); os.IsNotExist(err) && *configflag == defaultConfPath {
|
if _, err := os.Stat(defaultConfPath); os.IsNotExist(err) && *configflag == defaultConfPath {
|
||||||
// Read default from current directory
|
// Read default from current directory
|
||||||
|
|
18
rl.go
18
rl.go
|
@ -15,15 +15,19 @@ type lineReader struct {
|
||||||
var fileHist *fileHistory
|
var fileHist *fileHistory
|
||||||
|
|
||||||
// other gophers might hate this naming but this is local, shut up
|
// 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()
|
rl := readline.NewInstance()
|
||||||
fh, err := newFileHistory()
|
// we don't mind hilbish.read rl instances having completion,
|
||||||
fileHist = fh // go stupid
|
// but it cant have shared history
|
||||||
if err != nil {
|
if !noHist {
|
||||||
panic(err)
|
fh, err := newFileHistory()
|
||||||
|
fileHist = fh // go stupid
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
rl.SetHistoryCtrlR("file", fileHist)
|
||||||
|
rl.HistoryAutoWrite = false
|
||||||
}
|
}
|
||||||
rl.SetHistoryCtrlR("file", fileHist)
|
|
||||||
rl.HistoryAutoWrite = false
|
|
||||||
rl.ShowVimMode = false
|
rl.ShowVimMode = false
|
||||||
rl.ViModeCallback = func(mode readline.ViMode) {
|
rl.ViModeCallback = func(mode readline.ViMode) {
|
||||||
modeStr := ""
|
modeStr := ""
|
||||||
|
|
Loading…
Reference in New Issue