casouri / vundo

Visualize the undo tree.
413 stars 20 forks source link

draw: avoid overwriting existing branch char and make use of compact space if enabled #63

Closed jdtsmith closed 1 year ago

jdtsmith commented 1 year ago

I noticed that branch unicode characters never actually appear in buffer. They get replaced by vertical-stem:

○─○─○─○─○─○─○─○─○─○─○─○─○
  │─○   └─○─○─○─○─○─○─○─○─○─○─○─○─○─○─○─○─○─○─○─○─○─○─○─○─○
  │ └─○─○─○─○─○─○─○─○─○   └─○─○─○─○─○─○─○─○─○─○
  │   └─○─○─○─○       └─○   └─○─○─○─○─○─○─○─○
  └─○─○─○─○             └─○

What is happening is that as additional children beyond the first are drawn in, the is written over the top of . This PR fixes that by inserting only if the position is blank or eol (i.e. not overwriting).

I also harvest the one additional space available with vundo-compact-display.

Final result looks like:

○─○─○─○─○─○─○─○─○─○─○─○─○
  ├─○─○ └─○─○─○─○─○─○─○─○─○─○─○─○─○─○─○─○─○─○─○─○─○─○─○─○─○
  └─○ ├─○─○─○─○─○─○─○─○─○ └─○─○─○─○─○─○─○─○─○─○
    │ └─○─○─○─○         └─○ └─○─○─○─○─○─○─○─○
    └─○─○─○
jdtsmith commented 1 year ago

Just checking to see if you had had time to look into this @casouri. Pretty minor fix, related to #64 (which adds a clarifying feature).

casouri commented 1 year ago

Cool, I made some changes, could you test it out for me please? They are at fix-branch-char2 branch.

jdtsmith commented 1 year ago

Nice, thanks. I tested your version. It looks like in rare cases with "extra-long child branch connectors" where vundo has to make extra room for the next child, the branch char inadvertently gets used; check above the selected node.

I made this with my vundo-stress-test, btw, which I have found is a great way to make a random tree of a given branch width and density. [Side note: when this is used to prepare larger trees, vundo tends to hit assert errors; probably worth looking into at some point.]

image

casouri commented 1 year ago

Ah, I see, dumb mistake. I pushed the change.