diff --git a/spyderlib/plugins/editor.py b/spyderlib/plugins/editor.py index e9e98fd569c..27f2671455a 100644 --- a/spyderlib/plugins/editor.py +++ b/spyderlib/plugins/editor.py @@ -415,12 +415,14 @@ def __init__(self, parent, ignore_last_opened_files=False): # Change module completions when PYTHONPATH changes self.main.sig_pythonpath_changed.connect(self.set_path) - + # Find widget self.find_widget = FindReplace(self, enable_replace=True) self.find_widget.hide() + self.find_widget.visibility_changed.connect( + lambda vs: self.rehighlight_cells()) self.register_widget_shortcuts("Editor", self.find_widget) - + # Tabbed editor widget + Find/Replace widget editor_widgets = QWidget(self) editor_layout = QVBoxLayout() @@ -1049,9 +1051,8 @@ def save_focus_editorstack(self): #------ Handling editorstacks def register_editorstack(self, editorstack): self.editorstacks.append(editorstack) - self.register_widget_shortcuts("Editor", editorstack) - + if self.isAncestorOf(editorstack): # editorstack is a child of the Editor plugin self.set_last_focus_editorstack(self, editorstack) @@ -1410,7 +1411,13 @@ def update_todo_actions(self): and results is not None and len(results) self.todo_list_action.setEnabled(state) - + def rehighlight_cells(self): + """Rehighlight cells of current editor""" + editor = self.get_current_editor() + editor.rehighlight_cells() + QApplication.processEvents() + + #------ Breakpoints def save_breakpoints(self, filename, breakpoints): filename = to_text_string(filename) diff --git a/spyderlib/widgets/externalshell/start_ipython_kernel.py b/spyderlib/widgets/externalshell/start_ipython_kernel.py index 870943d6392..9b7c7348f71 100644 --- a/spyderlib/widgets/externalshell/start_ipython_kernel.py +++ b/spyderlib/widgets/externalshell/start_ipython_kernel.py @@ -53,20 +53,24 @@ def kernel_config(): # Pylab configuration mpl_installed = is_module_installed('matplotlib') pylab_o = CONF.get('ipython_console', 'pylab') - + if mpl_installed and pylab_o: - # Set matplotlib backend + # Get matplotlib backend backend_o = CONF.get('ipython_console', 'pylab/backend', 0) backends = {0: 'inline', 1: 'auto', 2: 'qt', 3: 'osx', 4: 'gtk', 5: 'wx', 6: 'tk'} mpl_backend = backends[backend_o] - spy_cfg.IPKernelApp.exec_lines.append( - "%matplotlib {0}".format(mpl_backend)) - # Automatically load Pylab and Numpy + # Automatically load Pylab and Numpy, or only set Matplotlib + # backend autoload_pylab_o = CONF.get('ipython_console', 'pylab/autoload') - spy_cfg.IPKernelApp.pylab_import_all = autoload_pylab_o - + if autoload_pylab_o: + spy_cfg.IPKernelApp.exec_lines.append( + "%pylab {0}".format(mpl_backend)) + else: + spy_cfg.IPKernelApp.exec_lines.append( + "%matplotlib {0}".format(mpl_backend)) + # Inline backend configuration if backends[backend_o] == 'inline': # Figure format @@ -181,10 +185,5 @@ def varexp(line): change_edit_magic(__ipythonshell__) __ipythonshell__.register_magic_function(varexp) -# To make %pylab load numpy and pylab even if the user has -# set autoload_pylab_o to False *but* nevertheless use it in -# the interactive session. -__ipythonkernel__.pylab_import_all = True - # Start the (infinite) kernel event loop. __ipythonkernel__.start() diff --git a/spyderlib/widgets/ipython.py b/spyderlib/widgets/ipython.py index 3600c6d1564..2738341ac15 100644 --- a/spyderlib/widgets/ipython.py +++ b/spyderlib/widgets/ipython.py @@ -456,7 +456,11 @@ def disable_stop_button(self): @Slot() def stop_button_click_handler(self): self.stop_button.setDisabled(True) - self.interrupt_kernel() + # Interrupt computations or stop debugging + if not self.shellwidget._reading: + self.interrupt_kernel() + else: + self.shellwidget.write_to_stdin('exit') def show_kernel_error(self, error): """Show kernel initialization errors in infowidget"""