Skip to content

Commit f3e53b0

Browse files
committed
Revert "compose: show relevant bindings on review screen"
This reverts commit effff93.
1 parent 40db4d0 commit f3e53b0

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"
@@ -1675,61 +1674,34 @@ type reviewMessage struct {
16751674
grid *ui.Grid
16761675
}
16771676

1677+
var reviewCommands = [][]string{
1678+
{":send<enter>", "Send"},
1679+
{":edit<enter>", "Edit"},
1680+
{":attach<space>", "Add attachment"},
1681+
{":detach<space>", "Remove attachment"},
1682+
{":postpone<enter>", "Postpone"},
1683+
{":preview<enter>", "Preview message"},
1684+
{":abort<enter>", "Abort (discard message, no confirmation)"},
1685+
{":choose -o d discard abort -o p postpone postpone<enter>", "Abort or postpone"},
1686+
}
1687+
16781688
func newReviewMessage(composer *Composer, err error) *reviewMessage {
16791689
bindings := config.Binds.ComposeReview.ForAccount(
16801690
composer.acctConfig.Name,
16811691
)
16821692

1683-
reviewCommands := [][]string{
1684-
{":send<enter>", "Send", ""},
1685-
{":edit<enter>", "Edit", ""},
1686-
{":attach<space>", "Add attachment", ""},
1687-
{":detach<space>", "Remove attachment", ""},
1688-
{":postpone<enter>", "Postpone", ""},
1689-
{":preview<enter>", "Preview message", ""},
1690-
{":abort<enter>", "Abort (discard message, no confirmation)", ""},
1691-
{":choose -o d discard abort -o p postpone postpone<enter>", "Abort or postpone", ""},
1692-
}
16931693
var actions []string
1694-
for _, binding := range bindings.Bindings {
1695-
inputs := config.FormatKeyStrokes(binding.Input)
1696-
outputs := config.FormatKeyStrokes(binding.Output)
1697-
outputs = strings.ReplaceAll(outputs, "<space>", " ")
1698-
found := false
1699-
for i, rcmd := range reviewCommands {
1700-
if outputs == rcmd[0] {
1701-
found = true
1702-
if reviewCommands[i][2] == "" {
1703-
reviewCommands[i][2] = inputs
1704-
} else {
1705-
reviewCommands[i][2] += ", " + inputs
1706-
}
1707-
break
1708-
}
1709-
}
1710-
if !found {
1711-
rcmd := []string{outputs, "", inputs}
1712-
reviewCommands = append(reviewCommands, rcmd)
1713-
}
1714-
}
1715-
longest := 0
1716-
for _, rcmd := range reviewCommands {
1717-
if len(rcmd[2]) > longest {
1718-
longest = len(rcmd[2])
1719-
}
1720-
}
1721-
1722-
width := longest
1723-
if longest < 6 {
1724-
width = 6
1725-
}
1726-
widthstr := strconv.Itoa(width)
17271694

1728-
for _, rcmd := range reviewCommands {
1729-
if rcmd[2] != "" {
1730-
actions = append(actions, fmt.Sprintf(" %-"+widthstr+"s %-40s %s",
1731-
rcmd[2], rcmd[1], rcmd[0]))
1695+
for _, command := range reviewCommands {
1696+
cmd := command[0]
1697+
name := command[1]
1698+
strokes, _ := config.ParseKeyStrokes(cmd)
1699+
var inputs []string
1700+
for _, input := range bindings.GetReverseBindings(strokes) {
1701+
inputs = append(inputs, config.FormatKeyStrokes(input))
17321702
}
1703+
actions = append(actions, fmt.Sprintf(" %-6s %-40s %s",
1704+
strings.Join(inputs, ", "), name, cmd))
17331705
}
17341706

17351707
spec := []ui.GridSpec{

0 commit comments

Comments
 (0)