File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,13 +60,13 @@ type editor struct {
6060 navigation * navigation
6161 listing * listingMode
6262
63+ restoreTerminal func () error
64+
6365 editorState
6466}
6567
6668type editorState struct {
6769 // States used during ReadLine. Reset at the beginning of ReadLine.
68- restoreTerminal func () error
69-
7070 notificationMutex sync.Mutex
7171
7272 notifications []string
@@ -313,7 +313,12 @@ func (ed *editor) startReadLine() error {
313313 }
314314 return err
315315 }
316- ed .restoreTerminal = restoreTerminal
316+ // Save the restore callback when Readline is called for the first time, and
317+ // reuse that callback. This is guard against commands that misbehave and
318+ // put the terminal in a bad state when it quits.
319+ if ed .restoreTerminal == nil {
320+ ed .restoreTerminal = restoreTerminal
321+ }
317322
318323 return nil
319324}
@@ -419,8 +424,7 @@ MainLoop:
419424 // Start over
420425 ed .mode .Teardown ()
421426 ed .editorState = editorState {
422- restoreTerminal : ed .restoreTerminal ,
423- isExternal : ed .isExternal ,
427+ isExternal : ed .isExternal ,
424428 }
425429 ed .SetModeInsert ()
426430 fresh = true
You can’t perform that action at this time.
0 commit comments