summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarsiarola <1andre234@gmail.com>2021-04-07 15:46:56 +0300
committerarsiarola <1andre234@gmail.com>2021-04-07 15:46:56 +0300
commit944c7dc6879d5ef4a1696cbbe3ac5a6f2030cc0e (patch)
treea0d5771a6a4d6a4d636b25c86503362a9270eafd
parent5045c4ab91f559a3735619dacf604e37632160cf (diff)
Fix marked_files out of bounds
If at start the parent directory contains only hidden files, and hidden option is turned off. And we move to the parent directory we will get: fff: line 293: marked_files: bad array subscript Found out this was due to $previous_index being 0 and -1 off of it. So $scroll and $scroll_start would end up being -1 Quick fix, store $previous_index starting from 0 rather than 1 just like $scroll variable. And don't minus 1 from it.
-rwxr-xr-xfff4
1 files changed, 2 insertions, 2 deletions
diff --git a/fff b/fff
index cee2cc9..85f2ecc 100755
--- a/fff
+++ b/fff
@@ -196,12 +196,12 @@ read_dir() {
for item in "$PWD"/*; do
if [[ -d $item ]]; then
dirs+=("$item")
- ((item_index++))
# Find the position of the child directory in the
# parent directory list.
[[ $item == "$OLDPWD" ]] &&
((previous_index=item_index))
+ ((item_index++))
else
files+=("$item")
fi
@@ -313,7 +313,7 @@ draw_dir() {
# When going up the directory tree, place the cursor on the position
# of the previous directory.
((find_previous == 1)) && {
- ((scroll_start=previous_index-1))
+ ((scroll_start=previous_index))
((scroll=scroll_start))
# Clear the directory history. We're here now.