Allow multiple specifications of kwds,ext,mime in completion specs

This commit is contained in:
Kovid Goyal 2023-03-20 13:42:36 +05:30
parent 41ea5f0c63
commit 4f5fc1000d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -36,9 +36,9 @@ class CompletionRelativeTo(Enum):
class CompletionSpec: class CompletionSpec:
type: CompletionType = CompletionType.none type: CompletionType = CompletionType.none
kwds: Sequence[str] = () kwds: Tuple[str,...] = ()
extensions: Sequence[str] = () extensions: Tuple[str,...] = ()
mime_patterns: Sequence[str] = () mime_patterns: Tuple[str,...] = ()
group: str = '' group: str = ''
relative_to: CompletionRelativeTo = CompletionRelativeTo.cwd relative_to: CompletionRelativeTo = CompletionRelativeTo.cwd
@ -50,13 +50,13 @@ class CompletionSpec:
if ck == 'type': if ck == 'type':
self.type = getattr(CompletionType, vv) self.type = getattr(CompletionType, vv)
elif ck == 'kwds': elif ck == 'kwds':
self.kwds = tuple(vv.split(',')) self.kwds += tuple(vv.split(','))
elif ck == 'ext': elif ck == 'ext':
self.extensions = tuple(vv.split(',')) self.extensions += tuple(vv.split(','))
elif ck == 'group': elif ck == 'group':
self.group = vv self.group = vv
elif ck == 'mime': elif ck == 'mime':
self.mime_patterns = tuple(vv.split(',')) self.mime_patterns += tuple(vv.split(','))
elif ck == 'relative': elif ck == 'relative':
if vv == 'conf': if vv == 'conf':
self.relative_to = CompletionRelativeTo.config_dir self.relative_to = CompletionRelativeTo.config_dir