calva icon indicating copy to clipboard operation
calva copied to clipboard

Drag sexp backwards command causes unexpected outcome in specific situation

Open bpringe opened this issue 1 year ago • 1 comments

(defn mirror-tree
  [tree]
  (when tree
    (let [[root left right] tree]
      [root (mirror-tree left) |(mirror-tree right)])))

When I put my cursor at | in the above code, in the bottom vector before the last sexp, and I run the command to drag the sexp backwards, it moves it to the front of the vector, rather than swapping it with the previous, as I expect.

Same thing happens if I put that code in a file by itself.

bpringe avatar Feb 22 '25 18:02 bpringe

I think I know what's happening. Calva probably misidentifies this as a let binding. (Within let, and other binding forms, the drag operations drag pairs. The result when dragging when there are an uneven number of elements in the binding form is somewhat undefined.)

PEZ avatar Feb 22 '25 19:02 PEZ