From 82b2d5ccde7fc82f90a8c2f0e29be08fa20164b0 2014-10-22 16:53:26
From: MinRK <benjaminrk@gmail.com>
Date: 2014-10-22 16:53:26
Subject: [PATCH] Qt: only trigger call tips automatically on open parenthesis

call tips were being requested on every change to the document, causing performance problems
---

diff --git a/IPython/qt/console/frontend_widget.py b/IPython/qt/console/frontend_widget.py
index 75a1825..064d037 100644
--- a/IPython/qt/console/frontend_widget.py
+++ b/IPython/qt/console/frontend_widget.py
@@ -700,10 +700,20 @@ class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):
     #---------------------------------------------------------------------------
     # 'FrontendWidget' protected interface
     #---------------------------------------------------------------------------
-
-    def _call_tip(self):
-        """ Shows a call tip, if appropriate, at the current cursor location.
+    
+    def _auto_call_tip(self):
+        """Trigger call tip automatically on open parenthesis
+        
+        Call tips can be requested explcitly with `_call_tip`.
         """
+        cursor = self._get_cursor()
+        cursor.movePosition(QtGui.QTextCursor.Left)
+        if cursor.document().characterAt(cursor.position()) == '(':
+            # trigger auto call tip on open paren
+            self._call_tip()
+    
+    def _call_tip(self):
+        """Shows a call tip, if appropriate, at the current cursor location."""
         # Decide if it makes sense to show a call tip
         if not self.enable_calltips or not self.kernel_client.shell_channel.is_alive():
             return False
@@ -785,7 +795,7 @@ class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):
 
         document = self._control.document()
         if position == self._get_cursor().position():
-            self._call_tip()
+            self._auto_call_tip()
 
     #------ Trait default initializers -----------------------------------------