Commit Graph

1007 Commits

Author SHA1 Message Date
Junegunn Choi d8bfb6712d
Remove invalid 'result' event when using --sync option
When the search for the initial query doesn't finish immediately
fzf would trigger an invalid 'result' event for an empty query.

  seq 100 | fzf --query 99 --bind result:accept --sync
    # Prints 99

  seq 1000000 | fzf --query 99 --bind result:accept --sync
    # Should print 99, but fzf would print 1
2024-04-20 14:42:43 +09:00
hidewrong 938f23e429
Fix typo in comment (#3734)
Signed-off-by: hidewrong <hidewrong@outlook.com>
2024-04-17 17:13:35 +09:00
Junegunn Choi 3acb4ca90e
Fix streaming filter mode by not running reader callback concurrently
Close #3728
2024-04-14 23:34:25 +09:00
Junegunn Choi e86b81bbf5
Improve search performance by limiting the search scope
Find the last occurrence of the last character in the pattern and
perform the search algorithm only up to that point.

The effectiveness of this mechanism depends a lot on the shape of the
input and the pattern.
2024-04-14 11:48:44 +09:00
Junegunn Choi a5447b8b75
Improve search performance by pre-calculating bonus matrix
This gives yet another 5% boost.
2024-04-14 11:47:06 +09:00
Junegunn Choi 7ce6452d83
Improve search performance by pre-calculating character classes
This simple optmization can give more than 15% performance boost
in some scenarios.
2024-04-14 11:47:05 +09:00
Charlie Vieth 3c877c504b
Enable profiling options when 'pprof' tag is set (#2813)
This commit enables cpu, mem, block, and mutex profling of the FZF
executable. To support flushing the profiles at program exit it adds
util.AtExit to register "at exit" functions and mandates that util.Exit
is used instead of os.Exit to stop the program.

Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
2024-04-13 14:58:11 +09:00
Junegunn Choi 892d1acccb
Fix tcell build 2024-04-13 14:47:04 +09:00
Junegunn Choi 1a9c282f76
Fix unit tests 2024-04-13 14:40:43 +09:00
Junegunn Choi fd1ba46f77
Export $FZF_KEY environment variable to child processes
It's the name of the last key pressed.

Related #3412
2024-04-13 14:00:16 +09:00
Junegunn Choi a4745626dd
Add jump and jump-cancel events
Close #3412

    # Default behavior
    fzf --bind space:jump

    # Same as jump-accept action
    fzf --bind space:jump,jump:accept

    # Accept on jump, abort on cancel
    fzf --bind space:jump,jump:accept,jump-cancel:abort

    # Change header on jump-cancel
    fzf --bind 'space:change-header(Type jump label)+jump,jump-cancel:change-header:Jump cancelled'
2024-04-10 20:17:12 +09:00
Junegunn Choi 4cd37fc02b
Disable line wrapping during rendering
Prevent unwanted line wraps that break the layout when the actual
display width of a character is different than expected.
2024-04-09 00:26:25 +09:00
Junegunn Choi 68a35e4735
Do not trim CR on Windows when --read0 is set 2024-04-04 23:39:29 +09:00
Junegunn Choi 8a2df79711
Do not hide separator by default on --info=inline-right|hidden 2024-04-04 00:05:55 +09:00
Junegunn Choi c30e486b64
Further performance improvements by removing unnecessary copies 2024-04-02 08:43:08 +09:00
Junegunn Choi 5234c3759a
Improve ingestion performance (by around 40%)
Summary
    fzf --sync --bind load:accept < 27M-lines ran
      1.16 ± 0.01 times faster than fzf-41b3511 --sync --bind load:accept < 27M-lines
      1.44 ± 0.01 times faster than fzf-0.48.1 --sync --bind load:accept < 27M-lines
2024-04-02 01:38:12 +09:00
Junegunn Choi 41b3511ad9
Improve ingestion performance (by around 20%) 2024-04-01 23:38:46 +09:00
Matthieu Cneude f625c5aabe
Add environment variables: FZF_{BORDER,PREVIEW}_LABEL (#3693)
The environment variable get the value of the preview label, even if it
has been updated with an action. It can be useful to track the label of
the preview and be able to switch between previews using only one
binding.

Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
2024-03-29 16:14:08 +09:00
Junegunn Choi 8a74976c1f
Add track-current, untrack-current, and toggle-track-current (#3699)
Close #3691
2024-03-28 20:42:01 +09:00
Junegunn Choi 008fb9d258
Fix reload and reload-sync behaviors
https://github.com/junegunn/fzf/discussions/3696#discussioncomment-8915593
2024-03-27 17:25:56 +09:00
Junegunn Choi db6db49ed6
Increase the buffer size for POST requests
Close #3685
2024-03-21 19:18:43 +09:00
Junegunn Choi 05453881c3
Set a 2-second timeout for POST requests
Close #3685
2024-03-21 19:18:38 +09:00
Junegunn Choi c7ee071efa
Fix panic caused by invalid cursor index
Fix #3681
2024-03-17 15:55:16 +09:00
Junegunn Choi 8977c9257a
Limit the maximum number of focus events to process at once 2024-03-14 11:18:47 +09:00
Junegunn Choi e74b1251c0
Embed shell integration scripts in fzf binary (`--bash` / `--zsh` / `--fish`) (#3675)
This simplifies the distribution, and the users are less likely to have
problems caused by using incompatible scripts and binaries.

    # Set up fzf key bindings and fuzzy completion
    eval "$(fzf --bash)"

    # Set up fzf key bindings and fuzzy completion
    eval "$(fzf --zsh)"

    # Set up fzf key bindings
    fzf --fish | source
2024-03-13 23:59:34 +09:00
Junegunn Choi d282a1649d
Add walker options and replace 'find' with the built-in walker (#3649) 2024-03-13 20:56:31 +09:00
Junegunn Choi 26244ad8c2
Fix preview area not being cleared when using certain types of border styles
fzf --preview 'sleep 3; date' --preview-window hidden \
      --bind ctrl-/:change-preview-window:up,border-bottom
2024-03-09 14:14:42 +09:00
Junegunn Choi fa0aa5510d
Kill preview process when hiding the preview window
via toggle-preview, hide-preview, or change-preview-window
2024-03-08 22:01:45 +09:00
Junegunn Choi eec557b6aa
Fix invalid memory access when the preview window becomes hidden 2024-03-08 17:57:09 +09:00
onee-only 61bc129e1d Update parseGetParams to call strconv.Atoi when params are valid 2024-03-05 11:03:56 +09:00
onee-only 52210a57f0 Update error return position according to convention 2024-03-05 11:03:56 +09:00
onee-only 8061a2f108 Remove duplicate code 2024-03-05 11:03:56 +09:00
Junegunn Choi 686f9288fc
Allow iTerm2 image data that ends with 'ESC \' (#3646) 2024-03-02 18:24:54 +09:00
Junegunn Choi 1833670fb9
Add $FZF_DEFAULT_OPTS_FILE (#3618)
For those who prefer to manage default options in a file.
If the file is not found, fzf will exit with an error.

We're not setting a default value for it because:

1. it's hard to find a default value that can be universally agreed upon
2. to avoid fzf having to check for the existence of the file even when it's not used
2024-02-29 09:49:33 +09:00
Junegunn Choi 99a7beba57
Fix missing bonus score on a delimiter character
Fix #3645
2024-02-22 23:19:11 +09:00
Junegunn Choi ca747a2b54
Fix unit tests 2024-02-19 12:39:04 +09:00
Junegunn Choi 5e6788c679
Export FZF_* variables to 'reload' process as well 2024-02-19 12:36:14 +09:00
Junegunn Choi 7a72f1a253
Code cleanup: Remove unused argument 2024-02-15 17:11:30 +09:00
Junegunn Choi 208e556332
Replace "default find command" with built-in directory traversal 2024-02-15 16:55:43 +09:00
Junegunn Choi 3c0a630475
0.46.1 2024-02-01 18:13:00 +09:00
Junegunn Choi 413c66beba
Fix tests for tcell build 2024-02-01 16:25:53 +09:00
Junegunn Choi 1416e696b1
Avoid full redraw on 'preview' action when preview window exists 2024-02-01 15:50:48 +09:00
Junegunn Choi d373cf89c7
Retain preview window on resize after 'preview' action 2024-02-01 15:46:42 +09:00
Junegunn Choi 76cf6559cc
junegunn/uniseg -> rivo/uniseg
https://github.com/rivo/uniseg/pull/47
2024-01-27 22:18:43 +09:00
Junegunn Choi da752fc9a4
Fix Windows build
Fix #3598
2024-01-24 15:59:54 +09:00
Junegunn Choi 2a8b65e105
Fix highlighting of regions that are matched multiple times
Fix #3596
2024-01-23 12:19:32 +09:00
Junegunn Choi 7484292e63
Avoid deadlocks by adding a 2 second timeout to GET / endpoint
Because fzf processes HTTP GET requests in the main event loop,
accessing the endpoint from within execute/transform actions would
result in a deadlock and hang fzf indefinitely. This commit sets
a 2 second timeout to avoid the deadlock.
2024-01-21 23:04:37 +09:00
Junegunn Choi 687c2741b8
Add 'resize' event
Close #3570
2024-01-21 15:30:59 +09:00
Junegunn Choi 16f6473938
Change mattn/go-runewidth dependency to rivo/uniseg for accurate results
Related #3588 #3588 #3567
2024-01-21 02:54:41 +09:00
Junegunn Choi 8a2c41e183
Handle ambiguous emoji width
Fix #3588
2024-01-19 16:41:50 +09:00