Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slurp-forward may cause syntax error by adding unmatched paren instead of slurping #1171

Closed
pbwolf opened this issue May 8, 2021 · 3 comments
Labels
bug Something isn't working paredit Paredit and structural editing

Comments

@pbwolf
Copy link

pbwolf commented May 8, 2021

Starting with this

(def foo
  (str
   )
  42)

Point within the str form, e.g., after the r
Slurp forward

(def foo
  (str)
  42))

The str did not embrace the following form, but instead lost some whitespace; and an unmatched close-paren, which Calva highlights in red, got added at the end of the following form.

Whitespace inside the end of the str form seems to be the key to the matter. If there is none, then slurp-forward works as expected by bringing the 42 into the str form.

Observed in Calva 2.0.195

@PEZ PEZ added bug Something isn't working paredit Paredit and structural editing labels May 9, 2021
@PEZ
Copy link
Collaborator

PEZ commented May 9, 2021

Thanks! I could reproduce this in a unit test.

How would we ideally want the form to look like after slurping? Using a | to mark the cursor here:

Before:

(def foo
  (str|
   )
  42)

After A (this is probably easiest to achieve):

(def foo
  (str|

  42))

After B:

(def foo
  (str|
  42))

After C:

(def foo
  (str| 42))

C has the advantage that if you want to keep 42 on the next line you can just press enter. OTOH, from A, B is just a ctrl+j away. (And C just another ctrl+j away.

I'll first see what seems simplest.

@PEZ
Copy link
Collaborator

PEZ commented May 9, 2021

As I guessed, option A was easiest so I implemented that. Please see the PR #1172 for some more details and request for help testing this.

@pbwolf
Copy link
Author

pbwolf commented May 10, 2021

Works great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working paredit Paredit and structural editing
Projects
None yet
Development

No branches or pull requests

2 participants