From 65283e661834a7282cac64b0c3442218bca1d618 Mon Sep 17 00:00:00 2001 From: gm10 <13855078+gm10@users.noreply.github.com> Date: Sun, 11 Aug 2019 23:55:34 +0200 Subject: moveItem: Remove redundant code, add missing check for move mode when merging entries --- Mozo/MenuEditor.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Mozo/MenuEditor.py b/Mozo/MenuEditor.py index 1db4feb..738456f 100644 --- a/Mozo/MenuEditor.py +++ b/Mozo/MenuEditor.py @@ -411,17 +411,18 @@ class MenuEditor(object): undo = [] if item.get_parent() != new_parent: # create new item - file_id = self.copyItem(item, new_parent) + self.copyItem(item, new_parent) # hide old item self.deleteItem(item) - item = ('Item', file_id) - self.__positionItem(new_parent, item, before, after) + else: + self.__positionItem(new_parent, item, before, after) undo.append(self.__getMenu(new_parent)) self.__addUndo(undo) - # merge the undo entries created by the previous operations in the - # correct order so we can undo in one go - items = self.__undo.pop()[::-1] + self.__undo.pop()[::-1] + self.__undo.pop()[::-1] - self.__undo.append(items[::-1]) + if item.get_parent() != new_parent: + # merge the undo entries created by the previous operations in the + # correct order so we can undo in one go + items = self.__undo.pop()[::-1] + self.__undo.pop()[::-1] + self.__undo.pop()[::-1] + self.__undo.append(items[::-1]) self.save() def moveMenu(self, menu, new_parent, before=None, after=None): -- cgit v1.2.1