From 6ed7a71a4d3e243ea80e9f0515190317243c4e57 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 20 Jun 2015 13:33:52 +0530 Subject: [PATCH] ... --- src/calibre/utils/rapydscript.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/calibre/utils/rapydscript.py b/src/calibre/utils/rapydscript.py index bf6ecaff26..bf5bf77989 100644 --- a/src/calibre/utils/rapydscript.py +++ b/src/calibre/utils/rapydscript.py @@ -223,12 +223,15 @@ class Repl(object): while True: try: prompt = self.ps2 if more else self.ps1 + lw = '' if more: lw = ' ' * 4 if self.lines: lw = leading_whitespace(self.lines[-1]) + lw + if hasattr(self, 'readline'): + self.readline.set_pre_input_hook(lambda:(self.readline.insert_text(lw), self.readline.redisplay())) + else: prompt += lw - try: line = raw_input(prompt).decode(self.enc) except EOFError: @@ -261,7 +264,8 @@ class Repl(object): except PYJError as e: for data in e.errors: msg = data.get('message') or '' - if data['line'] == len(self.lines) and 'Unexpected token: eof' in msg or 'Unterminated regular expression' in msg: + if data['line'] == len(self.lines) and data['col'] > 0 and ( + 'Unexpected token: eof' in msg or 'Unterminated regular expression' in msg): return True else: for e in e.errors: