This commit is contained in:
Kovid Goyal 2015-06-20 13:33:52 +05:30
parent 9f7c0f3911
commit 6ed7a71a4d

View File

@ -223,12 +223,15 @@ class Repl(object):
while True: while True:
try: try:
prompt = self.ps2 if more else self.ps1 prompt = self.ps2 if more else self.ps1
lw = ''
if more: if more:
lw = ' ' * 4 lw = ' ' * 4
if self.lines: if self.lines:
lw = leading_whitespace(self.lines[-1]) + lw 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 prompt += lw
try: try:
line = raw_input(prompt).decode(self.enc) line = raw_input(prompt).decode(self.enc)
except EOFError: except EOFError:
@ -261,7 +264,8 @@ class Repl(object):
except PYJError as e: except PYJError as e:
for data in e.errors: for data in e.errors:
msg = data.get('message') or '' 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 return True
else: else:
for e in e.errors: for e in e.errors: