mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-15 22:26:40 +02:00
use mutexes on escape code
This commit is contained in:
parent
83a895a463
commit
8e7f278094
2
go.mod
2
go.mod
@ -11,7 +11,7 @@ require (
|
|||||||
github.com/golang/protobuf v1.3.2 // indirect
|
github.com/golang/protobuf v1.3.2 // indirect
|
||||||
github.com/google/go-cmp v0.3.1 // indirect
|
github.com/google/go-cmp v0.3.1 // indirect
|
||||||
github.com/integrii/flaggy v1.4.0
|
github.com/integrii/flaggy v1.4.0
|
||||||
github.com/jesseduffield/gocui v0.3.1-0.20200112022728-874f1f64ada7
|
github.com/jesseduffield/gocui v0.3.1-0.20200112025325-6c933915c351
|
||||||
github.com/jesseduffield/pty v1.2.1
|
github.com/jesseduffield/pty v1.2.1
|
||||||
github.com/jesseduffield/rollrus v0.0.0-20190701125922-dd028cb0bfd7
|
github.com/jesseduffield/rollrus v0.0.0-20190701125922-dd028cb0bfd7
|
||||||
github.com/jesseduffield/termbox-go v0.0.0-20190630083001-9dd53af7214e // indirect
|
github.com/jesseduffield/termbox-go v0.0.0-20190630083001-9dd53af7214e // indirect
|
||||||
|
4
go.sum
4
go.sum
@ -79,8 +79,8 @@ github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOl
|
|||||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
|
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
|
||||||
github.com/jesseduffield/gocui v0.3.1-0.20191116013947-b13bda319532 h1:V1Lk2rm5/p27NjnlF2ezzkxDaisHNcveMNueSD7RYgs=
|
github.com/jesseduffield/gocui v0.3.1-0.20191116013947-b13bda319532 h1:V1Lk2rm5/p27NjnlF2ezzkxDaisHNcveMNueSD7RYgs=
|
||||||
github.com/jesseduffield/gocui v0.3.1-0.20191116013947-b13bda319532/go.mod h1:2RtZznzYKt8RLRwvFiSkXjU0Ei8WwHdubgnlaYH47dw=
|
github.com/jesseduffield/gocui v0.3.1-0.20191116013947-b13bda319532/go.mod h1:2RtZznzYKt8RLRwvFiSkXjU0Ei8WwHdubgnlaYH47dw=
|
||||||
github.com/jesseduffield/gocui v0.3.1-0.20200112022728-874f1f64ada7 h1:tUFXrq4adXbLukiRhHBDkmk306mhEzdxhEtKbix4FeQ=
|
github.com/jesseduffield/gocui v0.3.1-0.20200112025325-6c933915c351 h1:+sSqd2YotacWt+1MNRN8ZmXnYoiJeblZeptzKiHIyv0=
|
||||||
github.com/jesseduffield/gocui v0.3.1-0.20200112022728-874f1f64ada7/go.mod h1:2RtZznzYKt8RLRwvFiSkXjU0Ei8WwHdubgnlaYH47dw=
|
github.com/jesseduffield/gocui v0.3.1-0.20200112025325-6c933915c351/go.mod h1:2RtZznzYKt8RLRwvFiSkXjU0Ei8WwHdubgnlaYH47dw=
|
||||||
github.com/jesseduffield/pty v1.2.1 h1:7xYBiwNH0PpWqC8JmvrPq1a/ksNqyCavzWu9pbBGYWI=
|
github.com/jesseduffield/pty v1.2.1 h1:7xYBiwNH0PpWqC8JmvrPq1a/ksNqyCavzWu9pbBGYWI=
|
||||||
github.com/jesseduffield/pty v1.2.1/go.mod h1:7jlS40+UhOqkZJDIG1B/H21xnuET/+fvbbnHCa8wSIo=
|
github.com/jesseduffield/pty v1.2.1/go.mod h1:7jlS40+UhOqkZJDIG1B/H21xnuET/+fvbbnHCa8wSIo=
|
||||||
github.com/jesseduffield/roll v0.0.0-20190629104057-695be2e62b00 h1:+JaOkfBNYQYlGD7dgru8mCwYNEc5tRRI8mThlVANhSM=
|
github.com/jesseduffield/roll v0.0.0-20190629104057-695be2e62b00 h1:+JaOkfBNYQYlGD7dgru8mCwYNEc5tRRI8mThlVANhSM=
|
||||||
|
17
vendor/github.com/jesseduffield/gocui/escape.go
generated
vendored
17
vendor/github.com/jesseduffield/gocui/escape.go
generated
vendored
@ -5,8 +5,10 @@
|
|||||||
package gocui
|
package gocui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/go-errors/errors"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/go-errors/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type escapeInterpreter struct {
|
type escapeInterpreter struct {
|
||||||
@ -15,6 +17,7 @@ type escapeInterpreter struct {
|
|||||||
csiParam []string
|
csiParam []string
|
||||||
curFgColor, curBgColor Attribute
|
curFgColor, curBgColor Attribute
|
||||||
mode OutputMode
|
mode OutputMode
|
||||||
|
mutex sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
type escapeState int
|
type escapeState int
|
||||||
@ -34,6 +37,9 @@ var (
|
|||||||
|
|
||||||
// runes in case of error will output the non-parsed runes as a string.
|
// runes in case of error will output the non-parsed runes as a string.
|
||||||
func (ei *escapeInterpreter) runes() []rune {
|
func (ei *escapeInterpreter) runes() []rune {
|
||||||
|
ei.mutex.Lock()
|
||||||
|
defer ei.mutex.Unlock()
|
||||||
|
|
||||||
switch ei.state {
|
switch ei.state {
|
||||||
case stateNone:
|
case stateNone:
|
||||||
return []rune{0x1b}
|
return []rune{0x1b}
|
||||||
@ -66,6 +72,9 @@ func newEscapeInterpreter(mode OutputMode) *escapeInterpreter {
|
|||||||
|
|
||||||
// reset sets the escapeInterpreter in initial state.
|
// reset sets the escapeInterpreter in initial state.
|
||||||
func (ei *escapeInterpreter) reset() {
|
func (ei *escapeInterpreter) reset() {
|
||||||
|
ei.mutex.Lock()
|
||||||
|
defer ei.mutex.Unlock()
|
||||||
|
|
||||||
ei.state = stateNone
|
ei.state = stateNone
|
||||||
ei.curFgColor = ColorDefault
|
ei.curFgColor = ColorDefault
|
||||||
ei.curBgColor = ColorDefault
|
ei.curBgColor = ColorDefault
|
||||||
@ -76,6 +85,9 @@ func (ei *escapeInterpreter) reset() {
|
|||||||
// of an escape sequence, and as such should not be printed verbatim. Otherwise,
|
// of an escape sequence, and as such should not be printed verbatim. Otherwise,
|
||||||
// it's not an escape sequence.
|
// it's not an escape sequence.
|
||||||
func (ei *escapeInterpreter) parseOne(ch rune) (isEscape bool, err error) {
|
func (ei *escapeInterpreter) parseOne(ch rune) (isEscape bool, err error) {
|
||||||
|
ei.mutex.Lock()
|
||||||
|
defer ei.mutex.Unlock()
|
||||||
|
|
||||||
// Sanity checks
|
// Sanity checks
|
||||||
if len(ei.csiParam) > 20 {
|
if len(ei.csiParam) > 20 {
|
||||||
return false, errCSITooLong
|
return false, errCSITooLong
|
||||||
@ -179,6 +191,9 @@ func (ei *escapeInterpreter) outputNormal() error {
|
|||||||
// 0x11 - 0xe8: 216 different colors
|
// 0x11 - 0xe8: 216 different colors
|
||||||
// 0xe9 - 0x1ff: 24 different shades of grey
|
// 0xe9 - 0x1ff: 24 different shades of grey
|
||||||
func (ei *escapeInterpreter) output256() error {
|
func (ei *escapeInterpreter) output256() error {
|
||||||
|
ei.mutex.Lock()
|
||||||
|
defer ei.mutex.Unlock()
|
||||||
|
|
||||||
if len(ei.csiParam) < 3 {
|
if len(ei.csiParam) < 3 {
|
||||||
return ei.outputNormal()
|
return ei.outputNormal()
|
||||||
}
|
}
|
||||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -32,7 +32,7 @@ github.com/hashicorp/hcl/json/token
|
|||||||
github.com/integrii/flaggy
|
github.com/integrii/flaggy
|
||||||
# github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99
|
# github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99
|
||||||
github.com/jbenet/go-context/io
|
github.com/jbenet/go-context/io
|
||||||
# github.com/jesseduffield/gocui v0.3.1-0.20200112022728-874f1f64ada7
|
# github.com/jesseduffield/gocui v0.3.1-0.20200112025325-6c933915c351
|
||||||
github.com/jesseduffield/gocui
|
github.com/jesseduffield/gocui
|
||||||
# github.com/jesseduffield/pty v1.2.1
|
# github.com/jesseduffield/pty v1.2.1
|
||||||
github.com/jesseduffield/pty
|
github.com/jesseduffield/pty
|
||||||
|
Loading…
x
Reference in New Issue
Block a user