From 1495d3036ae30865bc83c0cb7d4d35ac8e33da2b Mon Sep 17 00:00:00 2001 From: zitong zhang Date: Tue, 3 Dec 2019 13:44:48 -0800 Subject: [PATCH] TTP-332 add modified source code --- CHANGELOG.md | 20 ----------------- Makefile | 12 +++++++++++ codes.go | 2 ++ cursor.go | 15 +++++++++++-- go.mod | 23 ++++++++++---------- go.sum | 27 ++++++----------------- prompt.go | 49 +++++++++++++++++++++++++++--------------- screenbuf/screenbuf.go | 48 ++++++++++++++++++++++++++++++++++++++++- select.go | 25 +++++++++------------ tools.go | 2 +- 10 files changed, 135 insertions(+), 88 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80b0e82..f9d97bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,26 +7,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Unreleased -## [0.6.0] - 2019-11-29 - -### Added - -- Support configurable stdin - -### Fixed - -- Correct the dep on go-i18n - -## [0.5.0] - 2019-11-29 - -### Added - -- Now building and testing on go 1.11, go 1.12, and go 1.13 - -### Removed - -- Removed support for Go versions that don't include modules. - ## [0.4.0] - 2019-02-19 ### Added diff --git a/Makefile b/Makefile index feb2700..bfc183a 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ +HAS_GO_MOD=$(shell go help mod; echo $$?) LINTERS=$(shell grep "// lint" tools.go | awk '{gsub(/\"/, "", $$1); print $$1}' | awk -F / '{print $$NF}') \ gofmt \ vet @@ -24,12 +25,23 @@ $(foreach cmd_pkg,$(CMD_PKGS),$(eval $(call VENDOR_BIN_TMPL,$(cmd_pkg)))) $(patsubst %,%-bin,$(filter-out gofmt vet,$(LINTERS))): %-bin: vendor/bin/% gofmt-bin vet-bin: +ifeq ($(HAS_GO_MOD),0) +bootstrap: + vendor: go.sum GO111MODULE=on go mod vendor +else +bootstrap: + which dep || go get -u github.com/golang/dep/cmd/dep + +vendor: Gopkg.lock + dep ensure -vendor-only +endif mod-update: GO111MODULE=on go get -u -m GO111MODULE=on go mod tidy + dep ensure -update mod-tidy: GO111MODULE=on go mod tidy diff --git a/codes.go b/codes.go index 8138c40..2a11acb 100644 --- a/codes.go +++ b/codes.go @@ -57,6 +57,8 @@ var ResetCode = fmt.Sprintf("%s%dm", esc, reset) const ( hideCursor = esc + "?25l" showCursor = esc + "?25h" + noLineWrap = esc + "\x1b[?7l" + doLineWrap = esc + "\x1b[?7h" clearLine = esc + "2K" ) diff --git a/cursor.go b/cursor.go index 959c800..c11fd9d 100644 --- a/cursor.go +++ b/cursor.go @@ -7,7 +7,7 @@ import "fmt" type Pointer func(to []rune) []rune func defaultCursor(ignored []rune) []rune { - return []rune("\u2588") + return []rune("\u2590") } func blockCursor(input []rune) []rune { @@ -15,7 +15,8 @@ func blockCursor(input []rune) []rune { } func pipeCursor(input []rune) []rune { - marker := []rune("|") + // change from "|" to be right half block(U+2590) to make it more explicit + marker := []rune("\u2590") out := []rune{} out = append(out, marker...) out = append(out, input...) @@ -128,6 +129,15 @@ func (c *Cursor) FormatMask(mask rune) string { return format(r, c) } +// FormatMask replaces all input runes with the mask rune. +func (c *Cursor) FormatMaskNoCursor(mask rune) string { + r := make([]rune, len(c.input)) + for i := range r { + r[i] = mask + } + return string(r) +} + // Update inserts newinput into the input []rune in the appropriate place. // The cursor is moved to the end of the inputed sequence. func (c *Cursor) Update(newinput string) { @@ -194,6 +204,7 @@ func (c *Cursor) Listen(line []rune, pos int, key rune) ([]rune, int, bool) { switch key { case 0: // empty case KeyEnter: + // keyEnter means this session ends, we should return false and let outside to check user input return []rune(c.Get()), c.Position, false case KeyBackspace: if c.erase { diff --git a/go.mod b/go.mod index 4d98174..e0337a6 100644 --- a/go.mod +++ b/go.mod @@ -1,19 +1,13 @@ module github.com/manifoldco/promptui -go 1.11 - -// Do not change the versions of kingpin or go-i18n; -// we will remove them when we stop using gometalinter - require ( - github.com/BurntSushi/toml v0.3.1 // indirect - github.com/alecthomas/gometalinter v3.0.0+incompatible - github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect + github.com/alecthomas/gometalinter v2.0.11+incompatible github.com/chzyer/logex v1.1.10 // indirect github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 // indirect github.com/client9/misspell v0.3.4 github.com/davecgh/go-spew v1.1.1 // indirect + github.com/golang/lint v0.0.0-20181026193005-c67002cb31c3 github.com/google/shlex v0.0.0-20181106134648-c34317bd91bf // indirect github.com/gordonklaus/ineffassign v0.0.0-20180909121442-1003c8bd00dc github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a @@ -21,11 +15,18 @@ require ( github.com/lunixbochs/vtclean v0.0.0-20180621232353-2d01aacdc34a // indirect github.com/mattn/go-colorable v0.0.9 // indirect github.com/mattn/go-isatty v0.0.4 // indirect - github.com/nicksnyder/go-i18n v1.10.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/stretchr/testify v1.2.2 // indirect github.com/tsenart/deadcode v0.0.0-20160724212837-210d2dc333e9 - golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3 + golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3 // indirect golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b // indirect golang.org/x/tools v0.0.0-20181122213734-04b5d21e00f1 // indirect - gopkg.in/alecthomas/kingpin.v3-unstable v3.0.0-20171010053543-63abe20a23e2 // indirect gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect ) + +// This version of kingpin is incompatible with the released version of +// gometalinter until the next release of gometalinter, and possibly until it +// has go module support, we'll need this exclude, and perhaps some more. +// +// After that point, we should be able to remove it. +exclude gopkg.in/alecthomas/kingpin.v3-unstable v3.0.0-20180810215634-df19058c872c diff --git a/go.sum b/go.sum index e49bef7..235128a 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,5 @@ -github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/alecthomas/gometalinter v3.0.0+incompatible h1:e9Zfvfytsw/e6Kd/PYd75wggK+/kX5Xn8IYDUKyc5fU= -github.com/alecthomas/gometalinter v3.0.0+incompatible/go.mod h1:qfIpQGGz3d+NmgyPBqv+LSh50emm1pt72EtcX2vKYQk= -github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E= -github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= +github.com/alecthomas/gometalinter v2.0.11+incompatible h1:toROE7pXPU/pUB4lh6ICqUKwpDtmkRCyJIr1nYqmKp0= +github.com/alecthomas/gometalinter v2.0.11+incompatible/go.mod h1:qfIpQGGz3d+NmgyPBqv+LSh50emm1pt72EtcX2vKYQk= github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8= @@ -12,10 +8,10 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWs github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/golang/lint v0.0.0-20181026193005-c67002cb31c3 h1:I4BOK3PBMjhWfQM2zPJKK7lOBGsrsvOB7kBELP33hiE= +github.com/golang/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= github.com/google/shlex v0.0.0-20181106134648-c34317bd91bf h1:7+FW5aGwISbqUtkfmIpZJGRgNFg2ioYPvFaUxdqpDsg= github.com/google/shlex v0.0.0-20181106134648-c34317bd91bf/go.mod h1:RpwtwJQFrIEPstU94h88MWPXP2ektJZ8cZ0YntAmXiE= github.com/gordonklaus/ineffassign v0.0.0-20180909121442-1003c8bd00dc h1:cJlkeAx1QYgO5N80aF5xRGstVsRQwgLR7uA2FnP1ZjY= @@ -33,15 +29,10 @@ github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRU github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/nicksnyder/go-i18n v1.10.1 h1:isfg77E/aCD7+0lD/D00ebR2MV5vgeQ276WYyDaCRQc= -github.com/nicksnyder/go-i18n v1.10.1/go.mod h1:e4Di5xjP9oTVrC6y3C7C0HoSYXjSbhh/dU0eUV32nB4= -github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= -github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/tsenart/deadcode v0.0.0-20160724212837-210d2dc333e9 h1:vY5WqiEon0ZSTGM3ayVVi+twaHKHDFUVloaQ/wug9/c= github.com/tsenart/deadcode v0.0.0-20160724212837-210d2dc333e9/go.mod h1:q+QjxYvZ+fpjMXqs+XEriussHjSYqeXVnAdSV1tkMYk= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3 h1:x/bBzNauLQAlE3fLku/xy92Y8QwKX5HZymrMz2IiKFc= @@ -50,11 +41,5 @@ golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b h1:MQE+LT/ABUuuvEZ+YQAMSXind golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/tools v0.0.0-20181122213734-04b5d21e00f1 h1:bsEj/LXbv3BCtkp/rBj9Wi/0Nde4OMaraIZpndHAhdI= golang.org/x/tools v0.0.0-20181122213734-04b5d21e00f1/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -gopkg.in/alecthomas/kingpin.v3-unstable v3.0.0-20171010053543-63abe20a23e2 h1:5zOHKFi4LqGWG+3d+isqpbPrN/2yhDJnlO+BhRiuR6U= -gopkg.in/alecthomas/kingpin.v3-unstable v3.0.0-20171010053543-63abe20a23e2/go.mod h1:3HH7i1SgMqlzxCcBmUHW657sD4Kvv9sC3HpL3YukzwA= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/prompt.go b/prompt.go index 8ef0719..0cb9483 100644 --- a/prompt.go +++ b/prompt.go @@ -7,9 +7,13 @@ import ( "text/template" "github.com/chzyer/readline" - "github.com/manifoldco/promptui/screenbuf" + + "tigergraph.com/thirdparty/promptui/screenbuf" ) +const default_prompt_placehold_size = 4 +const default_error_prompt_size = 3 + // Prompt represents a single line text field input with options for validation and input masks. type Prompt struct { // Label is the value displayed on the command line prompt. @@ -111,7 +115,12 @@ type PromptTemplates struct { // value. It will return the value and an error if any occurred during the prompt's execution. func (p *Prompt) Run() (string, error) { var err error - + //label should be only string + labelStr, ok := p.Label.(string) + if !ok { + return "", ErrAbort + } + promptLen := default_prompt_placehold_size + len(labelStr) err = p.prepareTemplates() if err != nil { return "", err @@ -138,6 +147,7 @@ func (p *Prompt) Run() (string, error) { } // we're taking over the cursor, so stop showing it. rl.Write([]byte(hideCursor)) + sb := screenbuf.New(rl) validFn := func(x string) error { @@ -154,9 +164,13 @@ func (p *Prompt) Run() (string, error) { } eraseDefault := input != "" && !p.AllowEdit cur := NewCursor(input, p.Pointer, eraseDefault) - + cursorLen := len(cur.Cursor([]rune{})) listen := func(input []rune, pos int, key rune) ([]rune, int, bool) { _, _, keepOn := cur.Listen(input, pos, key) + // if keepOn is false, we should return immediately + if !keepOn { + return nil, 0, keepOn + } err := validFn(cur.Get()) var prompt []byte @@ -173,16 +187,20 @@ func (p *Prompt) Run() (string, error) { if p.Mask != 0 { echo = cur.FormatMask(p.Mask) } - prompt = append(prompt, []byte(echo)...) + sb.Reset() - sb.Write(prompt) + // some cursor might have extra rune in the end of line + sb.WriteLineWrap(prompt, len([]rune(cur.input))+promptLen+cursorLen) + if inputErr != nil { + len := default_error_prompt_size + len(inputErr.Error()) validation := render(p.Templates.validation, inputErr) - sb.Write(validation) + + sb.WriteLineWrap(validation, len) inputErr = nil } - sb.Flush() + sb.FlushLineWrap() return nil, 0, keepOn } @@ -191,15 +209,14 @@ func (p *Prompt) Run() (string, error) { for { _, err = rl.Readline() inputErr = validFn(cur.Get()) + if inputErr == nil { break } - if err != nil { break } } - if err != nil { switch err { case readline.ErrInterrupt: @@ -211,16 +228,16 @@ func (p *Prompt) Run() (string, error) { err = ErrInterrupt } sb.Reset() - sb.WriteString("") - sb.Flush() rl.Write([]byte(showCursor)) rl.Close() + return "", err } - echo := cur.Format() + // this is when input value is correct, we don't show cursor + echo := string(cur.input) if p.Mask != 0 { - echo = cur.FormatMask(p.Mask) + echo = cur.FormatMaskNoCursor(p.Mask) } prompt := render(p.Templates.success, p.Label) @@ -233,13 +250,11 @@ func (p *Prompt) Run() (string, error) { err = ErrAbort } } - sb.Reset() - sb.Write(prompt) - sb.Flush() + sb.WriteLineWrap(prompt, len([]rune(cur.input))+promptLen) + sb.FlushLineWrap() rl.Write([]byte(showCursor)) rl.Close() - return cur.Get(), err } diff --git a/screenbuf/screenbuf.go b/screenbuf/screenbuf.go index 0fc24cc..022e235 100644 --- a/screenbuf/screenbuf.go +++ b/screenbuf/screenbuf.go @@ -4,6 +4,8 @@ import ( "bytes" "fmt" "io" + + "github.com/chzyer/readline" ) const esc = "\033[" @@ -70,7 +72,6 @@ func (s *ScreenBuf) Write(b []byte) (int, error) { return 0, err } } - switch { case s.cursor == s.height: n, err := s.buf.Write(clearLine) @@ -144,3 +145,48 @@ func (s *ScreenBuf) Flush() error { func (s *ScreenBuf) WriteString(str string) (int, error) { return s.Write([]byte(str)) } + +// hack method that fix the bug of duplicate lines when user input +// is longer than screen width + +// idea: the original code uses cursor to point current terminal line cursor, +// however the cursor is not accurate after "Moveup" or "Movedown". +// Here, since the linewrap will cause the actual line count > s.height, +// we need someway to recalc the height to make sure the output height is correct +// Then, by using s.Clear() func, which automatically clears all the lines and move cursor +// to the original position, we could simply output our content then in FlushLineWrap(). +func (s *ScreenBuf) WriteLineWrap(b []byte, outputLen int) (int, error) { + if bytes.ContainsAny(b, "\r\n") { + return 0, fmt.Errorf("%q should not contain either \\r or \\n", b) + } + + //reset will delete all previous lines and move cursor to the top + + if s.reset { + if err := s.Clear(); err != nil { + return 0, err + } + } + + s.height += outputLen / readline.GetScreenWidth() + if outputLen%readline.GetScreenWidth() != 0 { + s.height++ + } + + line := append(b, []byte("\n")...) + n, err := s.buf.Write(line) + if err != nil { + return n, err + } + return n, nil +} +func (s *ScreenBuf) FlushLineWrap() error { + //s.clearPreviousLines() + _, err := s.buf.WriteTo(s.w) + if err != nil { + return err + } + + s.buf.Reset() + return nil +} diff --git a/select.go b/select.go index f9e858d..4fc0c1a 100644 --- a/select.go +++ b/select.go @@ -9,8 +9,9 @@ import ( "github.com/chzyer/readline" "github.com/juju/ansiterm" - "github.com/manifoldco/promptui/list" - "github.com/manifoldco/promptui/screenbuf" + + "tigergraph.com/thirdparty/promptui/list" + "tigergraph.com/thirdparty/promptui/screenbuf" ) // SelectedAdd is used internally inside SelectWithAdd when the add option is selected in select mode. @@ -66,7 +67,7 @@ type Select struct { // it is implemented. Searcher list.Searcher - // StartInSearchMode sets whether or not the select mode should start in search mode or selection mode. + // StartInSearchMode sets whether or not the select mdoe should start in search mode or selection mode. // For search mode to work, the Search property must be implemented. StartInSearchMode bool @@ -76,9 +77,6 @@ type Select struct { // A function that determines how to render the cursor Pointer Pointer - - Stdin io.ReadCloser - Stdout io.WriteCloser } // SelectKeys defines the available keys used by select mode to enable the user to move around the list @@ -179,9 +177,6 @@ type SelectTemplates struct { help *template.Template } -// SearchPrompt is the prompt displayed in search mode. -var SearchPrompt = "Search: " - // Run executes the select list. It displays the label and the list of items, asking the user to chose any // value within to list. Run will keep the prompt alive until it has been canceled from // the command prompt or it has received a valid value. It will return the value and an error if any @@ -219,16 +214,14 @@ func (s *Select) RunCursorAt(cursorPos, scroll int) (int, string, error) { } func (s *Select) innerRun(cursorPos, scroll int, top rune) (int, string, error) { - c := &readline.Config{ - Stdin: s.Stdin, - Stdout: s.Stdout, - } + stdin := readline.NewCancelableStdin(os.Stdin) + c := &readline.Config{} err := c.Init() if err != nil { return 0, "", err } - c.Stdin = readline.NewCancelableStdin(c.Stdin) + c.Stdin = stdin if s.IsVimMode { c.VimMode = true @@ -243,6 +236,7 @@ func (s *Select) innerRun(cursorPos, scroll int, top rune) (int, string, error) } rl.Write([]byte(hideCursor)) + rl.Write([]byte(noLineWrap)) sb := screenbuf.New(rl) cur := NewCursor("", s.Pointer, false) @@ -295,7 +289,7 @@ func (s *Select) innerRun(cursorPos, scroll int, top rune) (int, string, error) } if searchMode { - header := SearchPrompt + cur.Format() + header := fmt.Sprintf("Search: %s", cur.Format()) sb.WriteString(header) } else if !s.HideHelp { help := s.renderHelp(canSearch) @@ -376,6 +370,7 @@ func (s *Select) innerRun(cursorPos, scroll int, top rune) (int, string, error) if err.Error() == "Interrupt" { err = ErrInterrupt } + clearScreen(sb) sb.Reset() sb.WriteString("") sb.Flush() diff --git a/tools.go b/tools.go index 1971b8e..c1356d2 100644 --- a/tools.go +++ b/tools.go @@ -5,7 +5,7 @@ package tools import ( "github.com/alecthomas/gometalinter" "github.com/client9/misspell/cmd/misspell" // lint + "github.com/golang/lint/golint" // lint "github.com/gordonklaus/ineffassign" // lint "github.com/tsenart/deadcode" // lint - "golang.org/x/lint/golint" // lint )