Commit 595cb0bd authored by Rok Mandeljc's avatar Rok Mandeljc

IPython: fixed the indentation when not using input splitter

In IPython 7.x, input_splitter is an instance of TransformManager2
and does not have indent_spaces attribute. Hence, we need to obtain
the indentation level from result of the check_complete() call on
the interactive shell object (IP).
parent ee74c204
......@@ -140,6 +140,7 @@ class IterableIPShell:
# But it definitely does not work any more with >= 7.0.0
self.no_input_splitter = parse_version(IPython.release.version) >= parse_version('5.8.0')
self.lines = []
self.indent_spaces = ''
def __update_namespace(self):
'''
......@@ -184,7 +185,8 @@ class IterableIPShell:
else:
if self.no_input_splitter:
self.lines.append(line)
self.iter_more = self.IP.check_complete('\n'.join(self.lines))[0] == 'incomplete'
(status, self.indent_spaces) = self.IP.check_complete('\n'.join(self.lines))
self.iter_more = status == 'incomplete'
else:
self.IP.input_splitter.push(line)
self.iter_more = self.IP.input_splitter.push_accepts_more()
......@@ -511,7 +513,10 @@ class ConsoleView(gtk.TextView):
self.text_buffer.place_cursor(self.text_buffer.get_end_iter())
if self.IP.rl_do_indent:
indentation = self.IP.input_splitter.indent_spaces * ' '
if self.no_input_splitter:
indentation = self.indent_spaces
else:
indentation = self.IP.input_splitter.indent_spaces * ' '
self.text_buffer.insert_at_cursor(indentation)
def onKeyPress(self, widget, event):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment