Skip to content

Commit 03ae4a5

Browse files
committed
Revert "compose: show relevant bindings on review screen"
This reverts commit effff93.
1 parent 62b8675 commit 03ae4a5

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
@@ -9,7 +9,6 @@ import (
99
"net/textproto"
1010
"os"
1111
"os/exec"
12-
"strconv"
1312
"strings"
1413
"sync"
1514
"sync/atomic"
@@ -1677,61 +1676,34 @@ type reviewMessage struct {
16771676
grid *ui.Grid
16781677
}
16791678

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

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

1730-
for _, rcmd := range reviewCommands {
1731-
if rcmd[2] != "" {
1732-
actions = append(actions, fmt.Sprintf(" %-"+widthstr+"s %-40s %s",
1733-
rcmd[2], rcmd[1], rcmd[0]))
1697+
for _, command := range reviewCommands {
1698+
cmd := command[0]
1699+
name := command[1]
1700+
strokes, _ := config.ParseKeyStrokes(cmd)
1701+
var inputs []string
1702+
for _, input := range bindings.GetReverseBindings(strokes) {
1703+
inputs = append(inputs, config.FormatKeyStrokes(input))
17341704
}
1705+
actions = append(actions, fmt.Sprintf(" %-6s %-40s %s",
1706+
strings.Join(inputs, ", "), name, cmd))
17351707
}
17361708

17371709
spec := []ui.GridSpec{

0 commit comments

Comments
 (0)