Skip to content

Commit

Permalink
Merge pull request spyder-ide#23090 from ccordoba12/backport-pr-22965
Browse files Browse the repository at this point in the history
Backport PR spyder-ide#22965 on branch 6.x (PR: Initial traceback setup to use selected syntax style (IPython Console))
  • Loading branch information
ccordoba12 authored Nov 27, 2024
2 parents 1e40941 + c63ab72 commit dff8e2d
Show file tree
Hide file tree
Showing 10 changed files with 217 additions and 25 deletions.
6 changes: 3 additions & 3 deletions external-deps/spyder-kernels/.gitrepo

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 28 additions & 7 deletions external-deps/spyder-kernels/spyder_kernels/console/kernel.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions external-deps/spyder-kernels/spyder_kernels/console/shell.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions external-deps/spyder-kernels/spyder_kernels/console/start.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions external-deps/spyder-kernels/spyder_kernels/customize/umr.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

138 changes: 138 additions & 0 deletions external-deps/spyder-kernels/spyder_kernels/utils/style.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion spyder/app/tests/test_mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -6499,7 +6499,7 @@ def test_clickable_ipython_tracebacks(main_window, qtbot, tmp_path):
control.setFocus()
find_widget = main_window.ipyconsole.get_widget().find_widget
find_widget.show()
find_widget.search_text.lineEdit().setText(' File')
find_widget.search_text.lineEdit().setText('File')
find_widget.find_previous()

# Position mouse on top of that line
Expand Down
12 changes: 11 additions & 1 deletion spyder/plugins/ipythonconsole/widgets/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ def __init__(
self._init_kernel_setup = False
self._is_banner_shown = False

# Set bright colors instead of bold formatting for better traceback
# readability.
self._ansi_processor.bold_text_enabled = False

if handlers is None:
handlers = {}
else:
Expand Down Expand Up @@ -697,7 +701,7 @@ def set_color_scheme(self, color_scheme, reset=True):
self.style_sheet, dark_color = create_qss_style(color_scheme)
self.syntax_style = color_scheme
self._style_sheet_changed()
self._syntax_style_changed()
self._syntax_style_changed(changed={})
if reset:
self.reset(clear=True)
if not self.spyder_kernel_ready:
Expand Down Expand Up @@ -1438,6 +1442,12 @@ def _syntax_style_changed(self, changed=None):
if self.syntax_style:
self._highlighter._style = create_style_class(self.syntax_style)
self._highlighter._clear_caches()
if changed is None:
return
self.set_kernel_configuration(
"traceback_highlight_style",
get_color_scheme(self.syntax_style),
)
else:
self._highlighter.set_style_sheet(self.style_sheet)

Expand Down
15 changes: 10 additions & 5 deletions spyder/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,21 @@ def remove_backslashes(path):

def get_error_match(text):
"""Check if text contains a Python error."""
# For regular Python tracebacks and IPython 7 or less.
# For regular Python tracebacks and IPython 7 or less (xmode plain).
match_python = re.match(r' File "(.*)", line (\d*)', text)
if match_python is not None:
return match_python

# For IPython 8+ tracebacks.
# For IPython 8+ tracebacks (xmode plain).
# Fixes spyder-ide/spyder#20407
ipython8_match = re.match(r' File (.*):(\d*)', text)
if ipython8_match is not None:
return ipython8_match
ipython8_plain_match = re.match(r' File (.*):(\d*)', text)
if ipython8_plain_match is not None:
return ipython8_plain_match

# For IPython 8+ tracebacks (xmode context).
ipython8_context_match = re.match(r'File (.*):(\d*)', text)
if ipython8_context_match is not None:
return ipython8_context_match

return False

Expand Down

0 comments on commit dff8e2d

Please sign in to comment.