@@ -23,9 +23,11 @@ class WordCompleter(Completer):
23
23
contain spaces. (Can not be used together with the WORD option.)
24
24
:param match_middle: When True, match not only the start, but also in the
25
25
middle of the word.
26
+ :param pattern: Optional regex. When given, use this regex
27
+ pattern instead of default one.
26
28
"""
27
29
def __init__ (self , words , ignore_case = False , meta_dict = None , WORD = False ,
28
- sentence = False , match_middle = False ):
30
+ sentence = False , match_middle = False , pattern = None ):
29
31
assert not (WORD and sentence )
30
32
assert callable (words ) or all (isinstance (w , string_types ) for w in words )
31
33
@@ -35,6 +37,7 @@ def __init__(self, words, ignore_case=False, meta_dict=None, WORD=False,
35
37
self .WORD = WORD
36
38
self .sentence = sentence
37
39
self .match_middle = match_middle
40
+ self .pattern = pattern
38
41
39
42
def get_completions (self , document , complete_event ):
40
43
# Get list of words.
@@ -46,7 +49,7 @@ def get_completions(self, document, complete_event):
46
49
if self .sentence :
47
50
word_before_cursor = document .text_before_cursor
48
51
else :
49
- word_before_cursor = document .get_word_before_cursor (WORD = self .WORD )
52
+ word_before_cursor = document .get_word_before_cursor (WORD = self .WORD , pattern = self . pattern )
50
53
51
54
if self .ignore_case :
52
55
word_before_cursor = word_before_cursor .lower ()
0 commit comments