refactor: use slices.Backward for reverse iteration (#2639)

This commit is contained in:
CatsDeservePets authored and GitHub committed 2026-07-10 02:08:16 +00:00
1 parent a417deceb9
commit 6fcec86740
2 files changed
+3 -6

No files matched your search

+2 -4
View File
@@ -563,8 +563,7 @@ func newUI(screen tcell.Screen) *ui {
}
func (ui *ui) winAt(x, y int) (int, *win) {
for i := len(ui.wins) - 1; i >= 0; i-- {
w := ui.wins[i]
for i, w := range slices.Backward(ui.wins) {
if x >= w.x && y >= w.y && y < w.y+w.h {
return i, w
}
@@ -1299,8 +1298,7 @@ func listJumps(jumps []string, ind int) string {
t.Init(b, 0, gOpts.tabstop, 2, '\t', 0)
fmt.Fprintln(t, " jump\tpath")
// print jumps in order of most recent, Vim uses the opposite order
for i := len(jumps) - 1; i >= 0; i-- {
path := jumps[i]
for i, path := range slices.Backward(jumps) {
switch {
case i < ind:
fmt.Fprintf(t, " %*d\t%s\n", maxlength, ind-i, path)