From 471757d6c63b5eab2ac5a4708c747299aa833b53 Mon Sep 17 00:00:00 2001 From: Asmageddon Date: Fri, 4 May 2012 20:57:16 +0200 Subject: [PATCH] Fix problems with moving selection caused by deluge-console emptying selection when only one element is selected --- deluge/ui/console/modes/torrent_actions.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/deluge/ui/console/modes/torrent_actions.py b/deluge/ui/console/modes/torrent_actions.py index 6bd5b4ba9..b54ed9bdf 100644 --- a/deluge/ui/console/modes/torrent_actions.py +++ b/deluge/ui/console/modes/torrent_actions.py @@ -86,7 +86,10 @@ def torrent_action(idx, data, mode, ids): if tq in mode.marked: selected_num += 1 if qact == ACTION.QUEUE_TOP: - mode.cursel = 1 + sorted(mode.marked).index(mode.cursel) + if mode.marked: + mode.cursel = 1 + sorted(mode.marked).index(mode.cursel) + else: + mode.cursel = 1 mode.marked = range(1, selected_num + 1) elif qact == ACTION.QUEUE_UP: mode.cursel = max(1, mode.cursel - 1) @@ -97,7 +100,10 @@ def torrent_action(idx, data, mode, ids): mode.marked = map(lambda v: v+1, mode.marked) mode.marked = filter(lambda v: v<=queue_length, mode.marked) elif qact == ACTION.QUEUE_BOTTOM: - mode.cursel = queue_length - selected_num + 1 + sorted(mode.marked).index(mode.cursel) + if mode.marked: + mode.cursel = queue_length - selected_num + 1 + sorted(mode.marked).index(mode.cursel) + else: + mode.cursel = queue_length mode.marked = range(queue_length - selected_num + 1, queue_length+1) if qact == ACTION.QUEUE_TOP: