Skip to content

Commit b2b3e28

Browse files
committed
Revert "compose: show relevant bindings on review screen"
This reverts commit effff93.
1 parent 0e3453e commit b2b3e28

File tree

1 file changed

+20
-48
lines changed

1 file changed

+20
-48
lines changed

widgets/compose.go

+20-48
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"net/textproto"
99
"os"
1010
"os/exec"
11-
"strconv"
1211
"strings"
1312
"sync"
1413
"sync/atomic"
@@ -1629,61 +1628,34 @@ type reviewMessage struct {
16291628
grid *ui.Grid
16301629
}
16311630

1631+
var reviewCommands = [][]string{
1632+
{":send<enter>", "Send"},
1633+
{":edit<enter>", "Edit"},
1634+
{":attach<space>", "Add attachment"},
1635+
{":detach<space>", "Remove attachment"},
1636+
{":postpone<enter>", "Postpone"},
1637+
{":preview<enter>", "Preview message"},
1638+
{":abort<enter>", "Abort (discard message, no confirmation)"},
1639+
{":choose -o d discard abort -o p postpone postpone<enter>", "Abort or postpone"},
1640+
}
1641+
16321642
func newReviewMessage(composer *Composer, err error) *reviewMessage {
16331643
bindings := config.Binds.ComposeReview.ForAccount(
16341644
composer.acctConfig.Name,
16351645
)
16361646

1637-
reviewCommands := [][]string{
1638-
{":send<enter>", "Send", ""},
1639-
{":edit<enter>", "Edit", ""},
1640-
{":attach<space>", "Add attachment", ""},
1641-
{":detach<space>", "Remove attachment", ""},
1642-
{":postpone<enter>", "Postpone", ""},
1643-
{":preview<enter>", "Preview message", ""},
1644-
{":abort<enter>", "Abort (discard message, no confirmation)", ""},
1645-
{":choose -o d discard abort -o p postpone postpone<enter>", "Abort or postpone", ""},
1646-
}
16471647
var actions []string
1648-
for _, binding := range bindings.Bindings {
1649-
inputs := config.FormatKeyStrokes(binding.Input)
1650-
outputs := config.FormatKeyStrokes(binding.Output)
1651-
outputs = strings.ReplaceAll(outputs, "<space>", " ")
1652-
found := false
1653-
for i, rcmd := range reviewCommands {
1654-
if outputs == rcmd[0] {
1655-
found = true
1656-
if reviewCommands[i][2] == "" {
1657-
reviewCommands[i][2] = inputs
1658-
} else {
1659-
reviewCommands[i][2] += ", " + inputs
1660-
}
1661-
break
1662-
}
1663-
}
1664-
if !found {
1665-
rcmd := []string{outputs, "", inputs}
1666-
reviewCommands = append(reviewCommands, rcmd)
1667-
}
1668-
}
1669-
longest := 0
1670-
for _, rcmd := range reviewCommands {
1671-
if len(rcmd[2]) > longest {
1672-
longest = len(rcmd[2])
1673-
}
1674-
}
1675-
1676-
width := longest
1677-
if longest < 6 {
1678-
width = 6
1679-
}
1680-
widthstr := strconv.Itoa(width)
16811648

1682-
for _, rcmd := range reviewCommands {
1683-
if rcmd[2] != "" {
1684-
actions = append(actions, fmt.Sprintf(" %-"+widthstr+"s %-40s %s",
1685-
rcmd[2], rcmd[1], rcmd[0]))
1649+
for _, command := range reviewCommands {
1650+
cmd := command[0]
1651+
name := command[1]
1652+
strokes, _ := config.ParseKeyStrokes(cmd)
1653+
var inputs []string
1654+
for _, input := range bindings.GetReverseBindings(strokes) {
1655+
inputs = append(inputs, config.FormatKeyStrokes(input))
16861656
}
1657+
actions = append(actions, fmt.Sprintf(" %-6s %-40s %s",
1658+
strings.Join(inputs, ", "), name, cmd))
16871659
}
16881660

16891661
spec := []ui.GridSpec{

0 commit comments

Comments
 (0)