Skip to content

Commit

Permalink
Merge from 2.3: Fix for issues #2314, #2299 and #2298
Browse files Browse the repository at this point in the history
  • Loading branch information
ccordoba12 committed Jun 11, 2015
2 parents d8293a0 + 2a6fc64 commit 6efb55d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
17 changes: 12 additions & 5 deletions spyderlib/plugins/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
23 changes: 11 additions & 12 deletions spyderlib/widgets/externalshell/start_ipython_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
6 changes: 5 additions & 1 deletion spyderlib/widgets/ipython.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down

0 comments on commit 6efb55d

Please sign in to comment.