Skip to content

Commit

Permalink
remove duplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
Bahadır Yağan committed Dec 19, 2019
1 parent ba5f2dd commit b163692
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/redial/redial.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,23 +107,15 @@ def on_key_press(self, key: str, w: UITreeWidget):
if i == len(parent_node.children) - 1: return # at bottom
parent_node.children[i], parent_node.children[i + 1] = parent_node.children[i + 1], parent_node.children[i]

save_ui_state(self.listbox)
Config.save_to_file(self.sessions)
self.walker.set_focus(UIParentNode(self.sessions, key_handler=self.on_key_press))
self.listbox.set_focus_to_node(this_node)
restore_ui_state(self.listbox, self.sessions)
self.save_and_focus(this_node)

elif key in ["meta up", "ctrl up"]:
if parent_node is None: return
i = parent_node.children.index(this_node)
if i == 0: return # at top
parent_node.children[i], parent_node.children[i - 1] = parent_node.children[i - 1], parent_node.children[i]

save_ui_state(self.listbox)
Config.save_to_file(self.sessions)
self.walker.set_focus(UIParentNode(self.sessions, key_handler=self.on_key_press))
self.listbox.set_focus_to_node(this_node)
restore_ui_state(self.listbox, self.sessions)
self.save_and_focus(this_node)
else:
return key

Expand Down

0 comments on commit b163692

Please sign in to comment.