diff --git a/app_state.py b/app_state.py index a68bd27..c054ae1 100644 --- a/app_state.py +++ b/app_state.py @@ -8,7 +8,7 @@ so later rebinding would only ever be seen by the module that did it. import configparser import os -VERSION = "0.0.0.077" +VERSION = "0.0.0.078" PROPERTIES_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "editor.properties") DEFAULT_GRID_SIZE = 10 DEFAULT_ADD_TIMESTAMP = True diff --git a/main.py b/main.py index 5db8dfe..ea2ae94 100644 --- a/main.py +++ b/main.py @@ -578,7 +578,7 @@ def on_canvas_wheel_zoom(event): def on_tree_select(event): """Triggered when a branch node is clicked in the Navigation view.""" - global _pending_link_selection + global _pending_link_selection, _restoring_selection # Read and cleared first thing, so a link a jump asked for is only ever picked out # by the very selection that jump made. A selection that turns out not to paint a @@ -621,8 +621,18 @@ def on_tree_select(event): ds.build_links_elements(sax_root) app_state.xml_root_element = sax_root sax_file.refresh_treeview_from_dom(sax_root) - # re-find the element after DOM rebuild - element = app_state.tree_element_map.get(selected_id) + # re-find element by comp id after DOM rebuild (tree item IDs changed) + element = None + for tid, elem in app_state.tree_element_map.items(): + if elem.get("id") == comp_id_str: + element = elem + selected_id = tid + break + if element is not None: + _restoring_selection = True + tree.selection_set(selected_id) + tree.see(selected_id) + tree.after_idle(_clear_restoring_flag) app_state.current_sheet_parent = element except Exception: pass