refactor: use slices.Backward for reverse iteration (#2639)
This commit is contained in:
1 parent
a417deceb9
commit
6fcec86740
2 files changed
+3
-6
No files matched your search
@@ -701,8 +701,7 @@ func (nav *nav) resize(ui *ui) {
|
|||||||
func (nav *nav) position() {
|
func (nav *nav) position() {
|
||||||
var base string
|
var base string
|
||||||
|
|
||||||
for i := len(nav.dirPaths) - 1; i >= 0; i-- {
|
for i, path := range slices.Backward(nav.dirPaths) {
|
||||||
path := nav.dirPaths[i]
|
|
||||||
if i < len(nav.dirPaths)-1 {
|
if i < len(nav.dirPaths)-1 {
|
||||||
nav.getDir(path).sel(base, nav.height)
|
nav.getDir(path).sel(base, nav.height)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -563,8 +563,7 @@ func newUI(screen tcell.Screen) *ui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ui *ui) winAt(x, y int) (int, *win) {
|
func (ui *ui) winAt(x, y int) (int, *win) {
|
||||||
for i := len(ui.wins) - 1; i >= 0; i-- {
|
for i, w := range slices.Backward(ui.wins) {
|
||||||
w := ui.wins[i]
|
|
||||||
if x >= w.x && y >= w.y && y < w.y+w.h {
|
if x >= w.x && y >= w.y && y < w.y+w.h {
|
||||||
return i, w
|
return i, w
|
||||||
}
|
}
|
||||||
@@ -1299,8 +1298,7 @@ func listJumps(jumps []string, ind int) string {
|
|||||||
t.Init(b, 0, gOpts.tabstop, 2, '\t', 0)
|
t.Init(b, 0, gOpts.tabstop, 2, '\t', 0)
|
||||||
fmt.Fprintln(t, " jump\tpath")
|
fmt.Fprintln(t, " jump\tpath")
|
||||||
// print jumps in order of most recent, Vim uses the opposite order
|
// print jumps in order of most recent, Vim uses the opposite order
|
||||||
for i := len(jumps) - 1; i >= 0; i-- {
|
for i, path := range slices.Backward(jumps) {
|
||||||
path := jumps[i]
|
|
||||||
switch {
|
switch {
|
||||||
case i < ind:
|
case i < ind:
|
||||||
fmt.Fprintf(t, " %*d\t%s\n", maxlength, ind-i, path)
|
fmt.Fprintf(t, " %*d\t%s\n", maxlength, ind-i, path)
|
||||||
|
|||||||
Reference in new issue
Block a user