Skip to content

Commit c14c362

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

File tree

1 file changed

+20
-48
lines changed

1 file changed

+20
-48
lines changed

app/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"
@@ -1673,61 +1672,34 @@ type reviewMessage struct {
16731672
grid *ui.Grid
16741673
}
16751674

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

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

1726-
for _, rcmd := range reviewCommands {
1727-
if rcmd[2] != "" {
1728-
actions = append(actions, fmt.Sprintf(" %-"+widthstr+"s %-40s %s",
1729-
rcmd[2], rcmd[1], rcmd[0]))
1693+
for _, command := range reviewCommands {
1694+
cmd := command[0]
1695+
name := command[1]
1696+
strokes, _ := config.ParseKeyStrokes(cmd)
1697+
var inputs []string
1698+
for _, input := range bindings.GetReverseBindings(strokes) {
1699+
inputs = append(inputs, config.FormatKeyStrokes(input))
17301700
}
1701+
actions = append(actions, fmt.Sprintf(" %-6s %-40s %s",
1702+
strings.Join(inputs, ", "), name, cmd))
17311703
}
17321704

17331705
spec := []ui.GridSpec{

0 commit comments

Comments
 (0)