dark icon indicating copy to clipboard operation
dark copied to clipboard

WIP - fixing reconstruction

Open StachuDotNet opened this issue 3 years ago • 2 comments
trafficstars

given the code

("hello",12345)

if I select between the two |s:

("he|llo",12|345)

Upon hitting 'delete' I expect the remaining state to be "he|"

The tuple will be killed as the deletions happen, so I expect the 12345 to disappear. Then, I should have the "hel" remaining, and be on the right side of the e.

Instead, I get "hel|" - one of the "l"s remains.


This seems to be because how deleteCaretRange works:

https://github.com/darklang/dark/blob/d6d113b9dc99bf8c2401fdd5ce01f4bf40ec2e72/client/src/fluid/Fluid.res#L4930-L4953

  • put the cursor at the RHS of the selection (in this case, 10)
  • record the 'col' of the LHS of the selection (in this case, 4)
  • hit 'backspace' until either:
    • the last backspace changed neither AST nor cursor position
    • the cursor is now at the recorded LHS

because the ( of the tuple is deleted, however, the initial LHS evaluation is sort of invalidated. The code thinks to go to position 4, but position 4 is eventualy between the 2 "l"s, rater than between "e" and "l".


My first attempt here was to rewrite the algorithm pretty dramatically. It works but breaks many other tests - will review and try again tomorrow.

StachuDotNet avatar Aug 16 '22 03:08 StachuDotNet

Note: I needed undo to work locally, so branched this off of my branch that fixes such.

StachuDotNet avatar Aug 16 '22 03:08 StachuDotNet

Haven't looked at the algorithm, but the way I would solve this is to use ASTRefs instead of positions

pbiggar avatar Aug 16 '22 15:08 pbiggar

this has been superseded by #4531

StachuDotNet avatar Oct 18 '22 17:10 StachuDotNet