@@ -20,7 +20,7 @@ namespace newsbeuter {
2020itemlist_formaction::itemlist_formaction (view * vv, std::string formstr)
2121 : formaction(vv,formstr), apply_filter(false ), update_visible_items(true ), show_searchresult(false ),
2222 search_dummy_feed (new rss_feed(v->get_ctrl ()->get_cache())),
23- set_filterpos(false ), filterpos(0 ), rxman(0 ), old_width(0 ) {
23+ set_filterpos(false ), filterpos(0 ), rxman(0 ), old_width(0 ), old_itempos(- 1 ) {
2424 assert (true ==m.parse (FILTER_UNREAD_ITEMS));
2525}
2626
@@ -43,6 +43,7 @@ void itemlist_formaction::process_operation(operation op, bool automatic, std::v
4343 GetLogger ().log (LOG_INFO, " itemlist_formaction: opening item at pos `%s'" , itemposname.c_str ());
4444 if (itemposname.length () > 0 ) {
4545 visible_items[itempos].first ->set_unread (false ); // set article as read
46+ old_itempos = itempos;
4647 v->push_itemview (feed, visible_items[itempos].first ->guid ());
4748 do_redraw = true ;
4849 } else {
@@ -647,6 +648,19 @@ int itemlist_formaction::get_pos(unsigned int realidx) {
647648void itemlist_formaction::recalculate_form () {
648649 formaction::recalculate_form ();
649650 set_update_visible_items (true );
651+
652+ std::string itemposname = f->get (" itempos" );
653+ unsigned int itempos = utils::to_u (itemposname);
654+
655+ // If the old position was set and it is less than the itempos, use it for the feed's itempos
656+ // Correct the problem when you open itemview and jump to next then exit to itemlist and the itempos is wrong
657+ // This only applies when "show-read-articles" is set to false
658+ if ( (old_itempos != -1 ) && itempos > (unsigned int )old_itempos
659+ && ! v->get_cfg ()->get_configvalue_as_bool (" show-read-articles" ) )
660+ {
661+ f->set (" itempos" , utils::strprintf (" %u" , old_itempos));
662+ old_itempos = -1 ; // Reset
663+ }
650664}
651665
652666void itemlist_formaction::save_article (const std::string& filename, std::tr1::shared_ptr<rss_item> item) {
0 commit comments