1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-02 03:37:14 +02:00

fix race condition

This commit is contained in:
Jesse Duffield 2021-04-12 23:05:52 +10:00
parent 7d195b97c2
commit 730a03a3b2
4 changed files with 10 additions and 11 deletions

2
go.mod
View File

@ -20,7 +20,7 @@ require (
github.com/imdario/mergo v0.3.11
github.com/integrii/flaggy v1.4.0
github.com/jesseduffield/go-git/v5 v5.1.2-0.20201006095850-341962be15a4
github.com/jesseduffield/gocui v0.3.1-0.20210412113212-ee65bd542c08
github.com/jesseduffield/gocui v0.3.1-0.20210412130453-de7bb5079f9f
github.com/jesseduffield/termbox-go v0.0.0-20200823212418-a2289ed6aafe // indirect
github.com/jesseduffield/yaml v2.1.0+incompatible
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0

2
go.sum
View File

@ -114,6 +114,8 @@ github.com/jesseduffield/gocui v0.3.1-0.20210412111008-6ef019af3724 h1:U70Do3/OS
github.com/jesseduffield/gocui v0.3.1-0.20210412111008-6ef019af3724/go.mod h1:QWq79xplEoyhQO+dgpk3sojjTVRKjQklyTlzm5nC5Kg=
github.com/jesseduffield/gocui v0.3.1-0.20210412113212-ee65bd542c08 h1:d003y2GByfR3PqN/JvxNuqyo8vx4m0epwY2hW7sNU80=
github.com/jesseduffield/gocui v0.3.1-0.20210412113212-ee65bd542c08/go.mod h1:QWq79xplEoyhQO+dgpk3sojjTVRKjQklyTlzm5nC5Kg=
github.com/jesseduffield/gocui v0.3.1-0.20210412130453-de7bb5079f9f h1:JPpHlvSrKNxro+K9rM3nEHCdZ16qD0hnEedHPF07OtA=
github.com/jesseduffield/gocui v0.3.1-0.20210412130453-de7bb5079f9f/go.mod h1:QWq79xplEoyhQO+dgpk3sojjTVRKjQklyTlzm5nC5Kg=
github.com/jesseduffield/termbox-go v0.0.0-20200823212418-a2289ed6aafe h1:qsVhCf2RFyyKIUe/+gJblbCpXMUki9rZrHuEctg6M/E=
github.com/jesseduffield/termbox-go v0.0.0-20200823212418-a2289ed6aafe/go.mod h1:anMibpZtqNxjDbxrcDEAwSdaJ37vyUeM1f/M4uekib4=
github.com/jesseduffield/yaml v2.1.0+incompatible h1:HWQJ1gIv2zHKbDYNp0Jwjlj24K8aqpFHnMCynY1EpmE=

View File

@ -131,6 +131,9 @@ func (v *View) EditGotoToEndOfLine() {
// EditDelete deletes a rune at the cursor position. back determines the
// direction.
func (v *View) EditDelete(back bool) {
v.writeMutex.Lock()
defer v.writeMutex.Unlock()
x, y := v.ox+v.cx, v.oy+v.cy
if y < 0 {
return
@ -177,6 +180,9 @@ func (v *View) EditDelete(back bool) {
// EditNewLine inserts a new line under the cursor.
func (v *View) EditNewLine() {
v.writeMutex.Lock()
defer v.writeMutex.Unlock()
v.breakLine(v.cx, v.cy)
v.ox = 0
v.cy = v.cy + 1
@ -397,9 +403,6 @@ func (v *View) writeRune(x, y int, ch rune) error {
// position corresponding to the point (x, y).
// returns the amount of columns that where removed.
func (v *View) deleteRune(x, y int) (int, error) {
v.writeMutex.Lock()
defer v.writeMutex.Unlock()
v.tainted = true
x, y, err := v.realPosition(x, y)
@ -427,9 +430,6 @@ func (v *View) deleteRune(x, y int) (int, error) {
// mergeLines merges the lines "y" and "y+1" if possible.
func (v *View) mergeLines(y int) error {
v.writeMutex.Lock()
defer v.writeMutex.Unlock()
v.clearViewLines()
_, y, err := v.realPosition(0, y)
@ -451,9 +451,6 @@ func (v *View) mergeLines(y int) error {
// breakLine breaks a line of the internal buffer at the position corresponding
// to the point (x, y).
func (v *View) breakLine(x, y int) error {
v.writeMutex.Lock()
defer v.writeMutex.Unlock()
v.tainted = true
x, y, err := v.realPosition(x, y)

2
vendor/modules.txt vendored
View File

@ -149,7 +149,7 @@ github.com/jesseduffield/go-git/v5/utils/merkletrie/filesystem
github.com/jesseduffield/go-git/v5/utils/merkletrie/index
github.com/jesseduffield/go-git/v5/utils/merkletrie/internal/frame
github.com/jesseduffield/go-git/v5/utils/merkletrie/noder
# github.com/jesseduffield/gocui v0.3.1-0.20210412113212-ee65bd542c08
# github.com/jesseduffield/gocui v0.3.1-0.20210412130453-de7bb5079f9f
## explicit
github.com/jesseduffield/gocui
# github.com/jesseduffield/termbox-go v0.0.0-20200823212418-a2289ed6aafe