From d571c080b542ec9df687051ec987d9ffae61e5be Mon Sep 17 00:00:00 2001 From: Yorhel <git@yorhel.nl> Date: Sat, 2 May 2009 13:01:12 +0200 Subject: [PATCH] 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... --- src/browser.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/browser.c b/src/browser.c index 7d2e226..0ce02b7 100644 --- a/src/browser.c +++ b/src/browser.c @@ -267,7 +267,7 @@ void browse_draw() { } /* 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)) continue; if(n->flags & FF_BSEL) { @@ -278,7 +278,7 @@ void browse_draw() { max = flags & BF_AS ? n->asize : n->size; i++; } - if(!selected) + if(selected < 0) cur->flags |= FF_BSEL; /* determine start position */ @@ -314,6 +314,7 @@ void browse_key_sel(int change) { if((cur = browse_dir) == NULL) return; par.next = cur; + par.flags = 0; if(cur->parent->parent) cur = ∥ @@ -410,6 +411,7 @@ int browse_key(int ch) { browse_dir = browse_dir->parent->parent->sub; sort++; } + browse_key_sel(0); nonfo++; break; case KEY_LEFT: @@ -417,6 +419,7 @@ int browse_key(int ch) { browse_dir = browse_dir->parent->parent->sub; sort++; } + browse_key_sel(0); nonfo++; break; @@ -479,5 +482,6 @@ void browse_init(struct dir *cur) { browse_dir = cur->parent->sub; if(browse_dir != NULL) browse_dir = browse_sort(browse_dir); + browse_key_sel(0); } -- GitLab