Skip to content

Commit c198b4f

Browse files
authored
describe: catch cursor blinking to avoid unnecessary rendering (#404)
Currently, cursor.Blink msg is not being filtered out and it causes describe view to re-render unnecessarily and height is being calculated on every blinking. This change adds a filter to catch and ignore blinking messages.
1 parent 3d9902e commit c198b4f

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

internal/ui/operations/describe/describe.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package describe
22

33
import (
4+
"github.com/charmbracelet/bubbles/cursor"
45
"github.com/charmbracelet/bubbles/key"
56
"github.com/charmbracelet/bubbles/textarea"
67
tea "github.com/charmbracelet/bubbletea"
@@ -12,8 +13,10 @@ import (
1213
"github.com/idursun/jjui/internal/ui/operations"
1314
)
1415

15-
var _ operations.Operation = (*Operation)(nil)
16-
var _ common.Editable = (*Operation)(nil)
16+
var (
17+
_ operations.Operation = (*Operation)(nil)
18+
_ common.Editable = (*Operation)(nil)
19+
)
1720

1821
type Operation struct {
1922
*common.ViewNode
@@ -55,6 +58,14 @@ func (o *Operation) Name() string {
5558
}
5659

5760
func (o *Operation) Update(msg tea.Msg) tea.Cmd {
61+
// ignore cursor blink messages to prevent unnecessary rendering and height
62+
// recalculations
63+
var cmd tea.Cmd
64+
if _, ok := msg.(cursor.BlinkMsg); ok {
65+
o.input, cmd = o.input.Update(msg)
66+
return cmd
67+
}
68+
5869
if keyMsg, ok := msg.(tea.KeyMsg); ok {
5970
switch {
6071
case key.Matches(keyMsg, o.keyMap.Cancel):
@@ -73,7 +84,6 @@ func (o *Operation) Update(msg tea.Msg) tea.Cmd {
7384
return o.context.RunCommand(jj.SetDescription(o.revision, o.input.Value()), common.Close, common.Refresh)
7485
}
7586
}
76-
var cmd tea.Cmd
7787
o.input, cmd = o.input.Update(msg)
7888

7989
newValue := o.input.Value()

0 commit comments

Comments
 (0)