Skip to content

Commit 0f063f2

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

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"
@@ -1686,62 +1685,35 @@ type reviewMessage struct {
16861685
grid *ui.Grid
16871686
}
16881687

1688+
var reviewCommands = [][]string{
1689+
{":send<enter>", "Send"},
1690+
{":edit<enter>", "Edit"},
1691+
{":attach<space>", "Add attachment"},
1692+
{":detach<space>", "Remove attachment"},
1693+
{":postpone<enter>", "Postpone"},
1694+
{":preview<enter>", "Preview message"},
1695+
{":abort<enter>", "Abort (discard message, no confirmation)"},
1696+
{":choose -o d discard abort -o p postpone postpone<enter>", "Abort or postpone"},
1697+
}
1698+
16891699
func newReviewMessage(composer *Composer, err error) *reviewMessage {
16901700
bindings := config.Binds.ComposeReview.ForAccount(
16911701
composer.acctConfig.Name,
16921702
)
16931703
bindings = bindings.ForFolder(composer.SelectedDirectory())
16941704

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

1740-
for _, rcmd := range reviewCommands {
1741-
if rcmd[2] != "" {
1742-
actions = append(actions, fmt.Sprintf(" %-"+widthstr+"s %-40s %s",
1743-
rcmd[2], rcmd[1], rcmd[0]))
1707+
for _, command := range reviewCommands {
1708+
cmd := command[0]
1709+
name := command[1]
1710+
strokes, _ := config.ParseKeyStrokes(cmd)
1711+
var inputs []string
1712+
for _, input := range bindings.GetReverseBindings(strokes) {
1713+
inputs = append(inputs, config.FormatKeyStrokes(input))
17441714
}
1715+
actions = append(actions, fmt.Sprintf(" %-6s %-40s %s",
1716+
strings.Join(inputs, ", "), name, cmd))
17451717
}
17461718

17471719
spec := []ui.GridSpec{

0 commit comments

Comments
 (0)