mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
fix(styles): fall back to default style if style not found (#4906)
The fallback is already the default behavior if the user has `pygments` installed, but if they don't we were awkwardly bailing out here and preventing startup.
This commit is contained in:
parent
5f5dab88c8
commit
2d75729962
2 changed files with 25 additions and 1 deletions
23
news/dont_crash_without_pygments.rst
Normal file
23
news/dont_crash_without_pygments.rst
Normal file
|
@ -0,0 +1,23 @@
|
|||
**Added:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Changed:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Deprecated:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Removed:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Fixed:**
|
||||
|
||||
* Warn and continue if a user without ``pygments`` tries to load an unknown style
|
||||
|
||||
**Security:**
|
||||
|
||||
* <news item>
|
|
@ -1149,7 +1149,8 @@ def ansi_style_by_name(name):
|
|||
if name in ANSI_STYLES:
|
||||
return ANSI_STYLES[name]
|
||||
elif not HAS_PYGMENTS:
|
||||
raise KeyError(f"could not find style {name!r}")
|
||||
print(f"could not find style {name!r}, using 'default'")
|
||||
return ANSI_STYLES["default"]
|
||||
from pygments.util import ClassNotFound
|
||||
|
||||
from xonsh.pygments_cache import get_style_by_name
|
||||
|
|
Loading…
Add table
Reference in a new issue