widget: defer op.StackOp in Editor.PaintCaret

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-07-09 20:34:15 +02:00
parent 39550f3239
commit 713770f808
+1 -2
View File
@@ -423,7 +423,7 @@ func (e *Editor) PaintCaret(gtx layout.Context) {
carX := e.caret.x carX := e.caret.x
carY := e.caret.y carY := e.caret.y
stack := op.Push(gtx.Ops) defer op.Push(gtx.Ops).Pop()
carX -= carWidth / 2 carX -= carWidth / 2
carAsc, carDesc := -e.lines[e.caret.line].Bounds.Min.Y, e.lines[e.caret.line].Bounds.Max.Y carAsc, carDesc := -e.lines[e.caret.line].Bounds.Min.Y, e.lines[e.caret.line].Bounds.Max.Y
carRect := image.Rectangle{ carRect := image.Rectangle{
@@ -448,7 +448,6 @@ func (e *Editor) PaintCaret(gtx layout.Context) {
if !carRect.Empty() { if !carRect.Empty() {
paint.PaintOp{Rect: layout.FRect(carRect)}.Add(gtx.Ops) paint.PaintOp{Rect: layout.FRect(carRect)}.Add(gtx.Ops)
} }
stack.Pop()
} }
// Len is the length of the editor contents. // Len is the length of the editor contents.