mirror of
https://github.com/peco/peco.git
synced 2026-09-10 07:16:29 -04:00
Merge pull request #411 from peco/topic/issue-410
Make Resume a blocking operation
This commit is contained in:
commit
fa9f5d593a
9
Changes
9
Changes
|
|
@ -2,8 +2,17 @@ Changes
|
|||
=======
|
||||
|
||||
v0.5.1 - unreleased
|
||||
Bugs/Fixes
|
||||
* When --exec is used, and you come back from the external command,
|
||||
you lost your selected location in the peco view. #410
|
||||
Backwards Incompatible Change:
|
||||
* --tty has been removed. it was not being used anyways.
|
||||
Miscellaneous
|
||||
* External commands specified in --exec now receive
|
||||
PECO_FILENAME, PECO_LINE_COUNT, PECO_QUERY, and
|
||||
PECO_MACHED_LINE_COUNT as environment variables
|
||||
* Removed unused structs
|
||||
* Fixed glide related Mkaefile actions
|
||||
|
||||
v0.5.0 - 06 Mar 2017
|
||||
Backwards Incompatible Change:
|
||||
|
|
|
|||
2
Makefile
2
Makefile
|
|
@ -8,7 +8,7 @@ VERSION=$(patsubst "%",%,$(lastword $(shell grep 'const version' peco.go)))
|
|||
RELEASE_DIR=releases
|
||||
ARTIFACTS_DIR=$(RELEASE_DIR)/artifacts/$(VERSION)
|
||||
SRC_FILES = $(wildcard *.go cmd/peco/*.go internal/*/*.go)
|
||||
HAVE_GLIDE:=$(shell which glide >/dev/null 2>&1 && echo "yes")
|
||||
HAVE_GLIDE:=$(shell (test -e $(INTERNAL_BIN_DIR)/$(THIS_GOOS)/$(THIS_GOARCH)/glide || which glide >/dev/null 2>&1 ) && echo "yes")
|
||||
GITHUB_USERNAME=peco
|
||||
BUILD_TARGETS= \
|
||||
build-linux-arm64 \
|
||||
|
|
|
|||
|
|
@ -356,7 +356,7 @@ func doFinish(ctx context.Context, state *Peco, _ termbox.Event) {
|
|||
|
||||
err = cmd.Run()
|
||||
state.screen.Resume()
|
||||
state.ExecQuery()
|
||||
state.Hub().SendDraw(&DrawOptions{DisableCache: true})
|
||||
if err != nil {
|
||||
// bail out, or otherwise the user cannot know what happened
|
||||
state.Exit(errors.Wrap(err, `failed to execute command`))
|
||||
|
|
|
|||
|
|
@ -162,8 +162,8 @@ type Screen interface {
|
|||
// Termbox just hands out the processing to the termbox library
|
||||
type Termbox struct {
|
||||
mutex sync.Mutex
|
||||
resumeCh chan (struct{})
|
||||
suspendCh chan (struct{})
|
||||
resumeCh chan chan struct{}
|
||||
suspendCh chan struct{}
|
||||
}
|
||||
|
||||
// View handles the drawing/updating the screen
|
||||
|
|
|
|||
13
screen.go
13
screen.go
|
|
@ -21,7 +21,7 @@ func (t *Termbox) Init() error {
|
|||
func NewTermbox() *Termbox {
|
||||
return &Termbox{
|
||||
suspendCh: make(chan struct{}),
|
||||
resumeCh: make(chan struct{}),
|
||||
resumeCh: make(chan chan struct{}),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -92,8 +92,9 @@ func (t *Termbox) PollEvent(ctx context.Context) chan termbox.Event {
|
|||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-t.resumeCh:
|
||||
case replyCh := <-t.resumeCh:
|
||||
t.Init()
|
||||
close(replyCh)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
|
@ -109,10 +110,16 @@ func (t *Termbox) Suspend() {
|
|||
}
|
||||
|
||||
func (t *Termbox) Resume() {
|
||||
// Resume must be a block operation, because we can't safely proceed
|
||||
// without actually knowing that termbox has been re-initialized.
|
||||
// So we send a channel where we expect a reply back, and wait for that
|
||||
ch := make(chan struct{})
|
||||
select {
|
||||
case t.resumeCh <- struct{}{}:
|
||||
case t.resumeCh <- ch:
|
||||
default:
|
||||
}
|
||||
|
||||
<-ch
|
||||
}
|
||||
|
||||
// SetCell writes to the terminal
|
||||
|
|
|
|||
Loading…
Reference in a new issue