mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-10-21 20:52:19 +00:00
...
This commit is contained in:
parent
ad41c365c8
commit
a16ad78de8
2 changed files with 10 additions and 10 deletions
|
|
@ -18,14 +18,14 @@ map = definition.add_map
|
|||
mma = definition.add_mouse_map
|
||||
|
||||
agr('scan', 'Scanning the filesystem')
|
||||
opt('+modify_score', r'(^|/)\.[^/]+(/|$) *= 0.5', add_to_default=True, long_text='''
|
||||
opt('+modify_score', r'(^|/)\.[^/]+(/|$) *= 0.1', add_to_default=True, long_text='''
|
||||
Modify the score of items matching the specified regular expression (matches against the absolute path).
|
||||
Can be used to make certain files and directories less or more prominent in the results.
|
||||
Can be specified multiple times. The default includes rules to reduce the score of hidden items and
|
||||
items in some well known cache folder names.
|
||||
items in some well known cache folder names. Only applies when some actual search expression is provided.
|
||||
The syntax is :code:`regular-expression operator value`. Supported operators are: :code:`*=, +=, -=, /=`.
|
||||
''')
|
||||
opt('+modify_score', '(^|/)__pycache__(/|$) *= 0.5', add_to_default=True)
|
||||
opt('+modify_score', '(^|/)__pycache__(/|$) *= 0.1', add_to_default=True)
|
||||
egr()
|
||||
|
||||
def main(args: list[str]) -> None:
|
||||
|
|
|
|||
|
|
@ -192,15 +192,15 @@ func (sc *ScanCache) scan(root_dir, search_text string, score_patterns []ScorePa
|
|||
patterns = patterns[1:]
|
||||
}
|
||||
}
|
||||
matches := sc.scan_dir(root_dir, patterns, nil, 0)
|
||||
for _, ri := range matches {
|
||||
ans = sc.scan_dir(root_dir, patterns, nil, 0)
|
||||
for _, ri := range ans {
|
||||
ri.score = get_modified_score(ri.abspath, ri.score, score_patterns)
|
||||
}
|
||||
if search_text == "" {
|
||||
ans = sort_items_without_search_text(matches)
|
||||
return
|
||||
has_search_text := search_text != "" && search_text != "/"
|
||||
if !has_search_text {
|
||||
return sort_items_without_search_text(ans)
|
||||
}
|
||||
slices.SortStableFunc(matches, func(a, b *ResultItem) int {
|
||||
slices.SortStableFunc(ans, func(a, b *ResultItem) int {
|
||||
ans := cmp.Compare(b.score, a.score)
|
||||
if ans == 0 {
|
||||
ans = cmp.Compare(len(a.text), len(b.text))
|
||||
|
|
@ -210,7 +210,7 @@ func (sc *ScanCache) scan(root_dir, search_text string, score_patterns []ScorePa
|
|||
}
|
||||
return ans
|
||||
})
|
||||
return matches
|
||||
return
|
||||
}
|
||||
|
||||
func (h *Handler) get_results() (ans []*ResultItem, in_progress bool) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue