[accerciser/gnome-3-34] IPython: fixed the indentation when not using input splitter



commit cd22dc6cbaab871440947c419f67f440ecdd629f
Author: Rok Mandeljc <rok mandeljc gmail com>
Date:   Thu Apr 16 20:31:32 2020 +0200

    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).

 plugins/ipython_view.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/plugins/ipython_view.py b/plugins/ipython_view.py
index 26765d7..317545b 100755
--- a/plugins/ipython_view.py
+++ b/plugins/ipython_view.py
@@ -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):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]