1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-05 00:59:19 +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

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)