forked from TrueCloudLab/rclone
ncdu: fix crashes on empty directories - fixes #1910
Up arrow or right arrow in an empty directory would crash ncdu
This commit is contained in:
parent
66558213e0
commit
2cf808c825
1 changed files with 2 additions and 2 deletions
|
@ -302,7 +302,7 @@ func (u *UI) move(d int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check dirPos.offset in bounds
|
// check dirPos.offset in bounds
|
||||||
if dirPos.offset < 0 {
|
if entries == 0 || dirPos.offset < 0 {
|
||||||
dirPos.offset = 0
|
dirPos.offset = 0
|
||||||
} else if dirPos.offset >= entries {
|
} else if dirPos.offset >= entries {
|
||||||
dirPos.offset = entries - 1
|
dirPos.offset = entries - 1
|
||||||
|
@ -392,7 +392,7 @@ func (u *UI) setCurrentDir(d *scan.Dir) {
|
||||||
|
|
||||||
// enters the current entry
|
// enters the current entry
|
||||||
func (u *UI) enter() {
|
func (u *UI) enter() {
|
||||||
if u.d == nil {
|
if u.d == nil || len(u.entries) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
dirPos := u.dirPosMap[u.path]
|
dirPos := u.dirPosMap[u.path]
|
||||||
|
|
Loading…
Add table
Reference in a new issue