From 730a03a3b245047f502581b1d1b2df8bce2b2310 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Mon, 12 Apr 2021 23:05:52 +1000 Subject: [PATCH] fix race condition --- go.mod | 2 +- go.sum | 2 ++ vendor/github.com/jesseduffield/gocui/edit.go | 15 ++++++--------- vendor/modules.txt | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 0625ede68..5da6012a8 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index b80707c08..573569b93 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/vendor/github.com/jesseduffield/gocui/edit.go b/vendor/github.com/jesseduffield/gocui/edit.go index 1e98468c4..ee6d7f604 100644 --- a/vendor/github.com/jesseduffield/gocui/edit.go +++ b/vendor/github.com/jesseduffield/gocui/edit.go @@ -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) diff --git a/vendor/modules.txt b/vendor/modules.txt index a458811c9..68c377230 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -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