@@ -332,7 +332,7 @@ func (s *Shell) initCompleters() {
332332}
333333
334334func (s * Shell ) setCompleter (completer readline.AutoCompleter ) {
335- config := s .reader .scanner .Config
335+ config := s .reader .scanner .Config . Clone ()
336336 config .AutoComplete = completer
337337 s .reader .scanner .SetConfig (config )
338338}
@@ -439,10 +439,11 @@ func (s *Shell) multiChoice(options []string, text string, init []int, multiResu
439439 s .multiChoiceActive = true
440440 defer func () { s .multiChoiceActive = false }()
441441
442- s .reader .scanner .Config .DisableAutoSaveHistory = true
443- defer func () { s .reader .scanner .Config .DisableAutoSaveHistory = false }()
442+ conf := s .reader .scanner .Config .Clone ()
443+
444+ conf .DisableAutoSaveHistory = true
444445
445- s . reader . scanner . Config .FuncFilterInputRune = func (r rune ) (rune , bool ) {
446+ conf .FuncFilterInputRune = func (r rune ) (rune , bool ) {
446447 switch r {
447448 case 16 :
448449 return - 1 , true
@@ -454,7 +455,6 @@ func (s *Shell) multiChoice(options []string, text string, init []int, multiResu
454455 }
455456 return r , true
456457 }
457- defer func () { s .reader .scanner .Config .FuncFilterInputRune = nil }()
458458
459459 var selected []int
460460 if multiResults {
@@ -537,8 +537,8 @@ func (s *Shell) multiChoice(options []string, text string, init []int, multiResu
537537 refresh <- struct {}{}
538538 return
539539 }
540- s . reader . scanner . Config .Listener = readline .FuncListener (listener )
541- defer func () { s .reader .scanner .Config . Listener = nil }( )
540+ conf .Listener = readline .FuncListener (listener )
541+ oldconf := s .reader .scanner .SetConfig ( conf )
542542
543543 stop := make (chan struct {})
544544 defer func () {
@@ -565,6 +565,8 @@ func (s *Shell) multiChoice(options []string, text string, init []int, multiResu
565565 }()
566566 s .ReadLine ()
567567
568+ s .reader .scanner .SetConfig (oldconf )
569+
568570 // only handles Ctrl-c for now
569571 // this can be broaden later
570572 switch lastKey {
0 commit comments