Skip to content
Snippets Groups Projects
Commit d571c080 authored by Yorhel's avatar Yorhel
Browse files

Fixed a browsing bug related to hiding items

Reproducable with the following steps:
- Make sure the first item in the list is a directory starting with a dot
- Make sure the next item is a normal directory
- Select first item
- Press 'h' to hide it, next item will properly be selected
- Open selected directory (right arrow), and see how the first (hidden)
  directory was opened.

It's amazing how I've even found this bug, considering that really is the
only way to reproduce it...
parent f416a7a1
No related branches found
No related tags found
No related merge requests found
...@@ -267,7 +267,7 @@ void browse_draw() { ...@@ -267,7 +267,7 @@ void browse_draw() {
} }
/* get maximum size and selected item */ /* get maximum size and selected item */
for(n=cur, selected=i=0; n!=NULL; n=n->next) { for(n=cur, selected=-1, i=0; n!=NULL; n=n->next) {
if(ishidden(n)) if(ishidden(n))
continue; continue;
if(n->flags & FF_BSEL) { if(n->flags & FF_BSEL) {
...@@ -278,7 +278,7 @@ void browse_draw() { ...@@ -278,7 +278,7 @@ void browse_draw() {
max = flags & BF_AS ? n->asize : n->size; max = flags & BF_AS ? n->asize : n->size;
i++; i++;
} }
if(!selected) if(selected < 0)
cur->flags |= FF_BSEL; cur->flags |= FF_BSEL;
/* determine start position */ /* determine start position */
...@@ -314,6 +314,7 @@ void browse_key_sel(int change) { ...@@ -314,6 +314,7 @@ void browse_key_sel(int change) {
if((cur = browse_dir) == NULL) if((cur = browse_dir) == NULL)
return; return;
par.next = cur; par.next = cur;
par.flags = 0;
if(cur->parent->parent) if(cur->parent->parent)
cur = &par; cur = &par;
...@@ -410,6 +411,7 @@ int browse_key(int ch) { ...@@ -410,6 +411,7 @@ int browse_key(int ch) {
browse_dir = browse_dir->parent->parent->sub; browse_dir = browse_dir->parent->parent->sub;
sort++; sort++;
} }
browse_key_sel(0);
nonfo++; nonfo++;
break; break;
case KEY_LEFT: case KEY_LEFT:
...@@ -417,6 +419,7 @@ int browse_key(int ch) { ...@@ -417,6 +419,7 @@ int browse_key(int ch) {
browse_dir = browse_dir->parent->parent->sub; browse_dir = browse_dir->parent->parent->sub;
sort++; sort++;
} }
browse_key_sel(0);
nonfo++; nonfo++;
break; break;
...@@ -479,5 +482,6 @@ void browse_init(struct dir *cur) { ...@@ -479,5 +482,6 @@ void browse_init(struct dir *cur) {
browse_dir = cur->parent->sub; browse_dir = cur->parent->sub;
if(browse_dir != NULL) if(browse_dir != NULL)
browse_dir = browse_sort(browse_dir); browse_dir = browse_sort(browse_dir);
browse_key_sel(0);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment