From 2f340f8049eb1f01eeff6e436eee50d24c799361 Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Wed, 26 Jul 2017 14:22:50 -0700 Subject: [PATCH] Save REPL history after an exception --- NEWS | 2 ++ hy/completer.py | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 3785792..300db30 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,8 @@ Changes from 0.13.0 * String literals should no longer be interpreted as special forms or macros * Tag macros (née sharp macros) whose names begin with `!` are no longer mistaken for shebang lines + * Fixed a bug where REPL history wasn't saved if you quit the REPL with + `(quit)` or `(exit)` Changes from 0.12.1 diff --git a/hy/completer.py b/hy/completer.py index 0d9c906..c4de45c 100644 --- a/hy/completer.py +++ b/hy/completer.py @@ -124,7 +124,8 @@ def completion(completer=None): readline.parse_and_bind(readline_bind) - yield - - if docomplete: - readline.write_history_file(history) + try: + yield + finally: + if docomplete: + readline.write_history_file(history)