summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorailurux <ailuruxx@gmail.com>2025-02-25 13:03:00 +1100
committerailurux <ailuruxx@gmail.com>2025-02-25 13:03:00 +1100
commit7a710966380350d6daa61e5a01f8b58e70bec0dc (patch)
tree67da90b2591174c335eccc6569b9d04c98716b13
parent8c262aee55076b80cc3e1d3d24eae0d377887af7 (diff)
downloadtangara-fw-7a710966380350d6daa61e5a01f8b58e70bec0dc.tar.gz
Fix bug with filesystem iterator prev off by one sometimes
-rw-r--r--src/tangara/lua/file_iterator.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/tangara/lua/file_iterator.cpp b/src/tangara/lua/file_iterator.cpp
index d2df8082..d318e255 100644
--- a/src/tangara/lua/file_iterator.cpp
+++ b/src/tangara/lua/file_iterator.cpp
@@ -46,15 +46,18 @@ auto FileIterator::next() -> void {
}
auto FileIterator::prev() -> void {
- if (offset_ == 0) {
+ f_rewinddir(&dir_);
+ if (offset_ <= 0) {
+ offset_ = -1;
current_.reset();
return;
}
- f_rewinddir(&dir_);
auto new_offset = offset_ - 1;
offset_ = -1;
while (offset_ < new_offset) {
- iterate(show_hidden_);
+ if (!iterate(show_hidden_)) {
+ break;
+ }
}
}