Index: tests/test_PluginRegistry.py =================================================================== --- tests/test_PluginRegistry.py (revision 81966) +++ tests/test_PluginRegistry.py (working copy) @@ -208,6 +208,19 @@ self.assertEqual( idlist[1], 'baz_plugin' ) self.assertEqual( idlist[2], 'foo_plugin' ) + # Moving the top plugin up should not change anything. + preg.movePluginsUp( IFoo, ( 'bar_plugin', ) ) + idlist = preg.listPluginIds( IFoo ) + self.assertEqual(idlist, + ('bar_plugin', 'baz_plugin', 'foo_plugin')) + + # Moving the top plugin and another one could change something. + preg.movePluginsUp( IFoo, ( 'bar_plugin', 'foo_plugin' ) ) + idlist = preg.listPluginIds( IFoo ) + self.assertEqual(idlist, + ('bar_plugin', 'foo_plugin', 'baz_plugin')) + + def test_movePluginsDown( self ): parent = DummyFolder() @@ -241,6 +254,18 @@ self.assertEqual( idlist[1], 'foo_plugin' ) self.assertEqual( idlist[2], 'bar_plugin' ) + # Moving the lowest plugin down should not change anything. + preg.movePluginsDown( IFoo, ( 'bar_plugin', ) ) + idlist = preg.listPluginIds( IFoo ) + self.assertEqual(idlist, + ('baz_plugin', 'foo_plugin', 'bar_plugin')) + + # Moving the lowest plugin and another one could change something. + preg.movePluginsDown( IFoo, ( 'bar_plugin', 'baz_plugin' ) ) + idlist = preg.listPluginIds( IFoo ) + self.assertEqual(idlist, + ('foo_plugin', 'baz_plugin', 'bar_plugin')) + def test_getAllPlugins( self ): parent = DummyFolder() Index: PluginRegistry.py =================================================================== --- PluginRegistry.py (revision 81966) +++ PluginRegistry.py (working copy) @@ -202,8 +202,9 @@ raise IndexError, i1 i2 = i1 - 1 - if i2 < 0: # wrap to bottom - i2 = len( ids ) - 1 + if i2 < 0: + # i1 is already on top + continue ids[ i2 ], ids[ i1 ] = ids[ i1 ], ids[ i2 ] @@ -227,8 +228,9 @@ raise IndexError, i1 i2 = i1 + 1 - if i2 == len( ids ): # wrap to top - i2 = 0 + if i2 == len( ids ): + # i1 is already on the bottom + continue ids[ i2 ], ids[ i1 ] = ids[ i1 ], ids[ i2 ]