Skip to content
This repository was archived by the owner on Oct 10, 2019. It is now read-only.

Commit d026700

Browse files
committed
Andreas Krennmair:
fixed issue #112 (patch by Isaac Good)
1 parent 356bb4d commit d026700

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Changes for newsbeuter:
22

33
1.4:
44
Added more flexible dialog handling
5+
Improved position handling in article list (fixes #112; thanks to Isaac Good)
56

67
1.3 (2008-12-06):
78
Changed some internal data structures to smart pointers (stability improvement).

include/itemlist_formaction.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class itemlist_formaction : public formaction {
8787
regexmanager * rxman;
8888

8989
unsigned int old_width;
90+
int old_itempos;
9091
};
9192

9293
}

src/itemlist_formaction.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace newsbeuter {
2020
itemlist_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) {
647648
void 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

652666
void itemlist_formaction::save_article(const std::string& filename, std::tr1::shared_ptr<rss_item> item) {

0 commit comments

Comments
 (0)