Commit Graph

64 Commits (master)

Author SHA1 Message Date
Zhizhen He 01e7668915
chore: use strings.ReplaceAll (#3801) 2 weeks ago
Junegunn Choi e8405f40fe
Refactor the code so that fzf can be used as a library (#3769) 4 weeks ago
onee-only 8061a2f108 Remove duplicate code 3 months ago
Junegunn Choi 38259d0382
Fix incorrect ordering of `--tiebreak=chunk` 2 years ago
Junegunn Choi bb0502ff44
Check gofmt in `make test` 3 years ago
Junegunn Choi f092e4038f
Smart match of accented characters
Fix #1618
4 years ago
Junegunn Choi 5624a89231
Inverse-only matches should not reorder the remaining results
Fix #1458
6 years ago
Ryan Boehning 21b94d2de5
Make fzf pass go vet
Add String() methods to types, so they can be printed with %s. Change
some %s format specifiers to %v, when the default string representation
is good enough. In Go 1.10, `go test` triggers a parallel `go vet`. So
this also makes fzf pass `go test`.

Close #1236
Close #1219
6 years ago
Junegunn Choi a2a4df0886
Pass util.Chars by pointer 7 years ago
Junegunn Choi 0d171ba1d8
Remove special nilItem 7 years ago
Junegunn Choi 6c76d8cd1c
Disallow escaping of meta characters except for spaces
https://github.com/junegunn/fzf/issues/444#issuecomment-321719604
7 years ago
Junegunn Choi a09e411936
Treat | as proper query when it can't be an OR operator 7 years ago
Junegunn Choi 02a7b96f33
Treat $ as proper search query
When $ is the leading character in a query, it's probably not meant to
be an anchor.
7 years ago
Junegunn Choi e55e029ae8
Build cache key for a pattern only once 7 years ago
Junegunn Choi 6b18b144cf
Fix escaping of meta characters after ' or ! prefix
https://github.com/junegunn/fzf/issues/444#issuecomment-321432803
7 years ago
Junegunn Choi 6d53089cc1
Allow escaping term starting with |
Close #444
7 years ago
Junegunn Choi e85a8a68d0
Allow escaping meta characters with backslashes
One can escape meta characters in extended-search mode with backslashes.

  Prefixes:
    \'
    \!
    \^

  Suffix:
    \$

  Term separator:
    \<SPACE>

To keep things simple, we are not going to support escaping of escaped
sequences (e.g. \\') for matching them literally.

Since this is a breaking change, we will bump the minor version.

Close #444
7 years ago
Junegunn Choi 999d374f0c
Fix invalid cache lookups 7 years ago
Junegunn Choi f4b46fad27
Inline function calls in a tight loop
Manually inline function calls in a tight loop as Go compiler does not
inline non-leaf functions. It is observed that this unpleasant code
change resulted up to 10% performance improvement.
7 years ago
Junegunn Choi c9f16b6430
Avoid unconditionally storsing input as runes
When --with-nth is used, fzf used to preprocess each line and store the
result as rune array, which was wasteful if the line only contains ascii
characters.
7 years ago
Junegunn Choi bbe10f4f77
Consolidate Result and rank structs
By not storing item index twice, we can cut down the size of Result
struct and now it makes more sense to store and pass Results by values.
Benchmarks show no degradation of performance by additional pointer
indirection for looking up index.
7 years ago
Junegunn Choi 9e85cba0d0
Reduce memory footprint of Item struct 7 years ago
Junegunn Choi 8dbdd55730
Refactor cache lookup
- Remove multiple mutex locks in partial cache lookup
- Simplify return values
7 years ago
Junegunn Choi d4f3d5a164
Remove pointer indirection by changing Chunk definition 7 years ago
Junegunn Choi 2e3dc75425
Fix inconsistent tiebreak scores when --nth is used
Make sure to consistently calculate tiebreak scores based on the
original line.

This change may not be preferable if you filter aligned tabular input on
a subset of columns using --nth. However, if we calculate length
tiebreak only on the matched components instead of the entire line, the
result can be very confusing when multiple --nth components are
specified, so let's keep it simple and consistent.

Close #926
7 years ago
Junegunn Choi dd1f26522c
Fix caching scheme when --exact is set and '-prefix is used 7 years ago
Junegunn Choi a16d8f66a9
Normalize pattern string before passing it to Algo function 8 years ago
Junegunn Choi 45793d75c2
Add --normalize option to normalize latin script characters
Close #790
8 years ago
Junegunn Choi aeb957a285
Use exact match by default for inverse search term
This is a breaking change, but I believe it makes much more sense. It is
almost impossible to predict which entries will be filtered out due to
a fuzzy inverse term. You can still perform inverse-fuzzy-match by
prepending `!'` to the term.

| Token    | Match type                 | Description                       |
| -------- | -------------------------- | --------------------------------- |
| `sbtrkt` | fuzzy-match                | Items that match `sbtrkt`         |
| `^music` | prefix-exact-match         | Items that start with `music`     |
| `.mp3$`  | suffix-exact-match         | Items that end with `.mp3`        |
| `'wild`  | exact-match (quoted)       | Items that include `wild`         |
| `!fire`  | inverse-exact-match        | Items that do not include `fire`  |
| `!.mp3$` | inverse-suffix-exact-match | Items that do not end with `.mp3` |
8 years ago
Junegunn Choi 2fc7c18747
Revise ranking algorithm 8 years ago
Junegunn Choi f8fdf9618a
No need to cache the result in filtering mode (--filter) 8 years ago
Junegunn Choi 827a83efbc
Remove Offset slice from Result struct 8 years ago
Junegunn Choi 37dc273148
Micro-optimizations
- Make structs smaller
- Introduce Result struct and use it to represent matched items instead of
  reusing Item struct for that purpose
- Avoid unnecessary memory allocation
- Avoid growing slice from the initial capacity
- Code cleanup
8 years ago
Junegunn Choi d4b6338102
Lint 8 years ago
Junegunn Choi 1d4057c209
[perf] Avoid allocating rune array for ascii string
In the best case (all ascii), this reduces the memory footprint by 60%
and the response time by 15% to 20%. In the worst case (every line has
non-ascii characters), 3 to 4% overhead is observed.
8 years ago
Junegunn Choi 85ef3263fc Fix incorrect cache reference in --exact mode (#547)
When we prepend a single quote to our query in --exact mode, we are not
supposed to limit the scope of the new search to the previous
exact-match result.
8 years ago
Junegunn Choi 2f6d23b91e Enhanced ranking algorithm
Based on the patch by Matt Westcott (@mjwestcott).
But with a more conservative approach:
- Does not use linearly increasing penalties; It is agreed upon that we
  should prefer matching characters at the beginnings of the words, but
  it's not always clear that the relevance is inversely proportional to
  the distance from the beginning.
- The approach here is more conservative in that the bonus is never
  large enough to override the matchlen, so it can be thought of as the
  first implicit tiebreak criterion.
- One may argue the change breaks the contract of --tiebreak, but the
  judgement depends on the definition of "tie".
8 years ago
Junegunn Choi 8d3a302a17 Simplify Item structure
This commit compensates for the performance overhead from the
extended tiebreak option.
9 years ago
Junegunn Choi 1d2d32c847 Accept comma-separated list of sort criteria 9 years ago
Junegunn Choi 31278bcc68 Fix compatibility issues with OR operator and inverse terms 9 years ago
Junegunn Choi e7e86b68f4 Add OR operator
Close #412
9 years ago
Junegunn Choi 81a88693c1 Make --extended default
Close #400
9 years ago
Junegunn Choi 92a75c9563 Use trimmed length when --nth is used with --tiebreak=length
This change improves sort ordering for aligned tabular input.
Given the following input:

    apple   juice   100
    apple   pie     200

fzf --nth=2 will now prefer the one with pie. Before this change fzf
compared "juice   " and "pie     ", both of which have the same length.
9 years ago
Junegunn Choi 64443221aa Fix #344 - Backward scan when `--tiebreak=end` 9 years ago
Junegunn Choi 9017e29741 Make it possible to unquote the term in extended-exact mode
Close #338
9 years ago
Junegunn Choi 766427de0c Fix --with-nth performance; avoid regex if possible
Close #317
9 years ago
Junegunn Choi 0ea66329b8 Performance tuning - eager rune array conversion
> wc -l /tmp/list2
     2594098 /tmp/list2

    > time cat /tmp/list2 | fzf-0.10.1-darwin_amd64 -fqwerty > /dev/null

    real    0m5.418s
    user    0m10.990s
    sys     0m1.302s

    > time cat /tmp/list2 | fzf-head -fqwerty > /dev/null

    real    0m4.862s
    user    0m6.619s
    sys     0m0.982s
9 years ago
Junegunn Choi 0be4cead20 Allow ^EqualMatch$ 9 years ago
Junegunn Choi e82eb27787 Smart-case for each term in extended-search mode
Close #208
9 years ago
Junegunn Choi 2fe1e28220 Improvements in performance and memory usage
I profiled fzf and it turned out that it was spending significant amount
of time repeatedly converting character arrays into Unicode codepoints.
This commit greatly improves search performance after the initial scan
by memoizing the converted results.

This commit also addresses the problem of unbounded memory usage of fzf.
fzf is a short-lived process that usually processes small input, so it
was implemented to cache the intermediate results very aggressively with
no notion of cache expiration/eviction. I still think a proper
implementation of caching scheme is definitely an overkill. Instead this
commit introduces limits to the maximum size (or minimum selectivity) of
the intermediate results that can be cached.
9 years ago