Update in response to feedback

- one configuration option: ignore_paths
- use shlex to parse option to support whitespace and in-line comments
- change option type to Tuple[str, ...]
- remove ignored directories from dirnames to prevent scanning
This commit is contained in:
Suvayu Ali
2022-06-06 09:58:18 +02:00
parent eea652f1d0
commit 20b6a97159
6 changed files with 26 additions and 31 deletions

View File

@@ -48,14 +48,11 @@ opt('replace_tab_by', '\\x20\\x20\\x20\\x20',
long_text='The string to replace tabs with. Default is to use four spaces.'
)
opt('file_ignores', '',
option_type='pattern_list',
long_text='List of file patterns that are ignored when directories are compared'
)
opt('ignore_paths', '',
option_type='pattern_list',
long_text='List of directory patterns that are ignored when directories are compared'
long_text='''List of patterns that are matched against directory and file
names and ignored when directories are compared.
''',
)
egr() # }}}

View File

@@ -86,10 +86,7 @@ class Parser:
for k in parse_map(val):
ans['map'].append(k)
def file_ignores(self, val: str, ans: typing.Dict[str, typing.List[str]]):
ans['file_ignores'] = pattern_list(val)
def ignore_paths(self, val: str, ans: typing.Dict[str, typing.List[str]]):
def ignore_paths(self, val: str, ans: typing.Dict[str, typing.Any]):
ans['ignore_paths'] = pattern_list(val)

View File

@@ -14,7 +14,6 @@ option_names = ( # {{{
'added_margin_bg',
'background',
'diff_cmd',
'file_ignores',
'filler_bg',
'foreground',
'highlight_added_bg',
@@ -45,14 +44,13 @@ class Options:
added_margin_bg: Color = Color(205, 255, 216)
background: Color = Color(255, 255, 255)
diff_cmd: str = 'auto'
file_ignores: typing.List[str] = ['']
filler_bg: Color = Color(250, 251, 252)
foreground: Color = Color(0, 0, 0)
highlight_added_bg: Color = Color(172, 242, 189)
highlight_removed_bg: Color = Color(253, 184, 192)
hunk_bg: Color = Color(241, 248, 255)
hunk_margin_bg: Color = Color(219, 237, 255)
ignore_paths: typing.List[str] = ['']
ignore_paths: typing.Tuple[str, ...] = ()
margin_bg: Color = Color(250, 251, 252)
margin_fg: Color = Color(170, 170, 170)
margin_filler_bg: typing.Optional[kitty.fast_data_types.Color] = None

View File

@@ -3,6 +3,7 @@
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
import shlex
from typing import Any, Dict, Iterable, List, Tuple, Union
from kitty.conf.utils import (
@@ -58,8 +59,8 @@ def syntax_aliases(raw: str) -> Dict[str, str]:
return ans
def pattern_list(raw: str) -> List[str]:
return raw.split(' ')
def pattern_list(raw: str) -> Tuple[str, ...]:
return tuple(shlex.split(raw, comments=True))
def parse_map(val: str) -> Iterable[KittensKeyDefinition]: