mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
This commit is contained in:
parent
09fcab65d2
commit
98d4d2a184
3 changed files with 37 additions and 6 deletions
23
news/fix_short_color_names.rst
Normal file
23
news/fix_short_color_names.rst
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
**Added:**
|
||||||
|
|
||||||
|
* <news item>
|
||||||
|
|
||||||
|
**Changed:**
|
||||||
|
|
||||||
|
* <news item>
|
||||||
|
|
||||||
|
**Deprecated:**
|
||||||
|
|
||||||
|
* <news item>
|
||||||
|
|
||||||
|
**Removed:**
|
||||||
|
|
||||||
|
* <news item>
|
||||||
|
|
||||||
|
**Fixed:**
|
||||||
|
|
||||||
|
* Short color token names can be used in ``register_custom_style()`` (#4339)
|
||||||
|
|
||||||
|
**Security:**
|
||||||
|
|
||||||
|
* <news item>
|
|
@ -365,6 +365,11 @@ def test_colorize_file_ca(xs_LS_COLORS, monkeypatch):
|
||||||
{"completion-menu.completion.current": "#00ff00"},
|
{"completion-menu.completion.current": "#00ff00"},
|
||||||
{Token.PTK.CompletionMenu.Completion.Current: "#00ff00"},
|
{Token.PTK.CompletionMenu.Completion.Current: "#00ff00"},
|
||||||
), # ptk style
|
), # ptk style
|
||||||
|
(
|
||||||
|
"test6",
|
||||||
|
{"RED": "#ff0000"},
|
||||||
|
{Token.Color.RED: "#ff0000"},
|
||||||
|
), # short color name
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_register_custom_pygments_style(name, styles, refrules):
|
def test_register_custom_pygments_style(name, styles, refrules):
|
||||||
|
|
|
@ -245,18 +245,21 @@ def color_token_by_name(xc: tuple, styles=None) -> _TokenType:
|
||||||
try:
|
try:
|
||||||
styles = XSH.shell.shell.styler.styles # type:ignore
|
styles = XSH.shell.shell.styler.styles # type:ignore
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return Color
|
pass
|
||||||
|
|
||||||
tokName = xc[0]
|
tokName = xc[0]
|
||||||
pc = color_name_to_pygments_code(xc[0], styles)
|
if styles:
|
||||||
|
pc = color_name_to_pygments_code(xc[0], styles)
|
||||||
|
|
||||||
if len(xc) > 1:
|
if len(xc) > 1:
|
||||||
pc += " " + color_name_to_pygments_code(xc[1], styles)
|
pc += " " + color_name_to_pygments_code(xc[1], styles)
|
||||||
tokName += "__" + xc[1]
|
tokName += "__" + xc[1]
|
||||||
|
|
||||||
token = getattr(Color, norm_name(tokName))
|
token = getattr(Color, norm_name(tokName))
|
||||||
if token not in styles or not styles[token]:
|
|
||||||
|
if styles and (token not in styles or not styles[token]):
|
||||||
styles[token] = pc
|
styles[token] = pc
|
||||||
|
|
||||||
return token
|
return token
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue