There are possibly many ways to specify which node should be expanded. Some
of them are more sensitive to outline changes than others. Here is an idea
of encoding expanded positions in more robust way.
When traversing outline we can encounter same v node several times if it is
cloned. A pair (v, count) where count is integer showing how many times
this same v node was seen during the traversal, can be used to make
distinction between clones. The first occurrence of v is encoded as (v,
0). The second occurrence is encoded as (v, 1),...
Now if we want to know whether the position p should be expanded, the
following code (untested) might give the answer:
def should_p_be_expanded(p, expanded): # expanded is a set of pairs (v, i)
v = p.v
for i, p1 in enumerate(sorted(c.all_positions_for_v(v))):
if p1 != p: continue
return (v, i) in expanded
return False
Of course if p.v has no clones then, correct answer is just p.v.isExpanded()
This scheme can also be broken by outline change, when this change affects
ordering of clones, but it is resilient against inserting and deleting new
nodes, and moving nodes that are not ancestors of a node. That covers a lot
of more frequent kinds of outline changes.
My 2 cents.
Vitalije
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/leo-editor/e0cefb2b-5baf-47db-825a-6d8245840d59o%40googlegroups.com.