Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: junegunn/fzf
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 21ce70054f4f65efafcd056d1101f1040187c8d4
Choose a base ref
...
head repository: junegunn/fzf
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0012183ede3619e2bf52932c196377f8a7befbf6
Choose a head ref
  • 2 commits
  • 7 files changed
  • 1 contributor

Commits on Mar 3, 2025

  1. [windows] Prevent fzf from consuming user input while paused

    This partly fixes #4260.
    
    fzf still can consume the first key stroke.
    junegunn committed Mar 3, 2025
    Copy the full SHA
    8916cbc View commit details
  2. 0.60.3

    junegunn committed Mar 3, 2025
    Copy the full SHA
    0012183 View commit details
Showing with 55 additions and 35 deletions.
  1. +12 −0 CHANGELOG.md
  2. +1 −1 install
  3. +1 −1 install.ps1
  4. +1 −1 man/man1/fzf-tmux.1
  5. +1 −1 man/man1/fzf.1
  6. +3 −4 src/tui/light.go
  7. +36 −27 src/tui/light_windows.go
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
CHANGELOG
=========

0.60.3
------
- Bug fixes and improvements
- [fish] Enable multiple history commands insertion (#4280) (@bitraid)
- [walker] Append '/' to directory entries on MSYS2 (#4281)
- Trim trailing whitespaces after processing ANSI sequences (#4282)
- Remove temp files before `become` when using `--tmux` option (#4283)
- Fix condition for using item numlines cache (#4285) (@alex-huff)
- Make `--accept-nth` compatible with `--select-1` (#4287)
- Increase the query length limit from 300 to 1000 (#4292)
- [windows] Prevent fzf from consuming user input while paused (#4260)

0.60.2
------
- Template for `--with-nth` and `--accept-nth` now supports `{n}` which evaluates to the zero-based ordinal index of the item
2 changes: 1 addition & 1 deletion install
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

set -u

version=0.60.2
version=0.60.3
auto_completion=
key_bindings=
update_config=2
2 changes: 1 addition & 1 deletion install.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$version="0.60.2"
$version="0.60.3"

$fzf_base=Split-Path -Parent $MyInvocation.MyCommand.Definition

2 changes: 1 addition & 1 deletion man/man1/fzf-tmux.1
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
..
.TH fzf\-tmux 1 "Feb 2025" "fzf 0.60.2" "fzf\-tmux - open fzf in tmux split pane"
.TH fzf\-tmux 1 "Mar 2025" "fzf 0.60.3" "fzf\-tmux - open fzf in tmux split pane"

.SH NAME
fzf\-tmux - open fzf in tmux split pane
2 changes: 1 addition & 1 deletion man/man1/fzf.1
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
..
.TH fzf 1 "Feb 2025" "fzf 0.60.2" "fzf - a command-line fuzzy finder"
.TH fzf 1 "Mar 2025" "fzf 0.60.3" "fzf - a command-line fuzzy finder"

.SH NAME
fzf - a command-line fuzzy finder
7 changes: 3 additions & 4 deletions src/tui/light.go
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ import (
"regexp"
"strconv"
"strings"
"sync"
"time"
"unicode/utf8"

@@ -95,7 +96,6 @@ func (r *LightRenderer) flushRaw(sequence string) {

// Light renderer
type LightRenderer struct {
closed *util.AtomicBool
theme *ColorTheme
mouse bool
forceBlack bool
@@ -120,6 +120,7 @@ type LightRenderer struct {
showCursor bool

// Windows only
mutex sync.Mutex
ttyinChannel chan byte
inHandle uintptr
outHandle uintptr
@@ -151,7 +152,6 @@ func NewLightRenderer(ttyin *os.File, theme *ColorTheme, forceBlack bool, mouse
out = os.Stderr
}
r := LightRenderer{
closed: util.NewAtomicBool(false),
theme: theme,
forceBlack: forceBlack,
mouse: mouse,
@@ -775,9 +775,8 @@ func (r *LightRenderer) Close() {
}
r.disableMouse()
r.flush()
r.closePlatform()
r.restoreTerminal()
r.closed.Set(true)
r.closePlatform()
}

func (r *LightRenderer) Top() int {
63 changes: 36 additions & 27 deletions src/tui/light_windows.go
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ const (
var (
consoleFlagsInput = uint32(windows.ENABLE_VIRTUAL_TERMINAL_INPUT | windows.ENABLE_PROCESSED_INPUT | windows.ENABLE_EXTENDED_FLAGS)
consoleFlagsOutput = uint32(windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING | windows.ENABLE_PROCESSED_OUTPUT | windows.DISABLE_NEWLINE_AUTO_RETURN)
counter = uint64(0)
)

// IsLightRendererSupported checks to see if the Light renderer is supported
@@ -61,27 +62,11 @@ func (r *LightRenderer) initPlatform() error {
}
r.inHandle = uintptr(inHandle)

r.setupTerminal()

// channel for non-blocking reads. Buffer to make sure
// we get the ESC sets:
r.ttyinChannel = make(chan byte, 1024)

// the following allows for non-blocking IO.
// syscall.SetNonblock() is a NOOP under Windows.
go func() {
fd := int(r.inHandle)
b := make([]byte, 1)
for !r.closed.Get() {
// HACK: if run from PSReadline, something resets ConsoleMode to remove ENABLE_VIRTUAL_TERMINAL_INPUT.
_ = windows.SetConsoleMode(windows.Handle(r.inHandle), consoleFlagsInput)

_, err := util.Read(fd, b)
if err == nil {
r.ttyinChannel <- b[0]
}
}
}()
r.setupTerminal()

return nil
}
@@ -100,18 +85,42 @@ func openTtyOut() (*os.File, error) {
return os.Stderr, nil
}

func (r *LightRenderer) setupTerminal() error {
if err := windows.SetConsoleMode(windows.Handle(r.outHandle), consoleFlagsOutput); err != nil {
return err
}
return windows.SetConsoleMode(windows.Handle(r.inHandle), consoleFlagsInput)
func (r *LightRenderer) setupTerminal() {
windows.SetConsoleMode(windows.Handle(r.outHandle), consoleFlagsOutput)
windows.SetConsoleMode(windows.Handle(r.inHandle), consoleFlagsInput)

// The following allows for non-blocking IO.
// syscall.SetNonblock() is a NOOP under Windows.
current := counter
go func() {
fd := int(r.inHandle)
b := make([]byte, 1)
for {
if _, err := util.Read(fd, b); err == nil {
r.mutex.Lock()
// This condition prevents the goroutine from running after the renderer
// has been closed or paused.
if current != counter {
r.mutex.Unlock()
break
}
r.ttyinChannel <- b[0]
// HACK: if run from PSReadline, something resets ConsoleMode to remove ENABLE_VIRTUAL_TERMINAL_INPUT.
windows.SetConsoleMode(windows.Handle(r.inHandle), consoleFlagsInput)
r.mutex.Unlock()
}
}
}()
}

func (r *LightRenderer) restoreTerminal() error {
if err := windows.SetConsoleMode(windows.Handle(r.inHandle), r.origStateInput); err != nil {
return err
}
return windows.SetConsoleMode(windows.Handle(r.outHandle), r.origStateOutput)
func (r *LightRenderer) restoreTerminal() {
r.mutex.Lock()
counter++
// We're setting ENABLE_VIRTUAL_TERMINAL_INPUT to allow escape sequences to be read during 'execute'.
// e.g. fzf --bind 'enter:execute:less {}'
windows.SetConsoleMode(windows.Handle(r.inHandle), r.origStateInput|windows.ENABLE_VIRTUAL_TERMINAL_INPUT)
windows.SetConsoleMode(windows.Handle(r.outHandle), r.origStateOutput)
r.mutex.Unlock()
}

func (r *LightRenderer) Size() TermSize {