##// END OF EJS Templates
Fix completing options for %colors magic...
Thomas Kluyver -
Show More
@@ -1274,10 +1274,14 b' class IPCompleter(Completer):'
1274
1274
1275 def magic_color_matches(self, text:str) -> List[str] :
1275 def magic_color_matches(self, text:str) -> List[str] :
1276 """ Match color schemes for %colors magic"""
1276 """ Match color schemes for %colors magic"""
1277 texts = text.strip().split()
1277 texts = text.split()
1278
1278 if text.endswith(' '):
1279 if len(texts) > 0 and (texts[0] == 'colors' or texts[0] == '%colors'):
1279 # .split() strips off the trailing whitespace. Add '' back
1280 prefix = texts[1] if len(texts) > 1 else ''
1280 # so that: '%colors ' -> ['%colors', '']
1281 texts.append('')
1282
1283 if len(texts) == 2 and (texts[0] == 'colors' or texts[0] == '%colors'):
1284 prefix = texts[1]
1281 return [ color for color in InspectColors.keys()
1285 return [ color for color in InspectColors.keys()
1282 if color.startswith(prefix) ]
1286 if color.startswith(prefix) ]
1283 return []
1287 return []
@@ -628,6 +628,8 b' def test_magic_color():'
628 nt.assert_in('%colors', matches)
628 nt.assert_in('%colors', matches)
629 s, matches = c.complete(None, 'colo')
629 s, matches = c.complete(None, 'colo')
630 nt.assert_not_in('NoColor', matches)
630 nt.assert_not_in('NoColor', matches)
631 s, matches = c.complete(None, '%colors') # No trailing space
632 nt.assert_not_in('NoColor', matches)
631 s, matches = c.complete(None, 'colors ')
633 s, matches = c.complete(None, 'colors ')
632 nt.assert_in('NoColor', matches)
634 nt.assert_in('NoColor', matches)
633 s, matches = c.complete(None, '%colors ')
635 s, matches = c.complete(None, '%colors ')
General Comments 0
You need to be logged in to leave comments. Login now