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

Paredit auto collapsing whitespace left of the cursor is disorienting #1862

Open
skylize opened this issue Sep 12, 2022 · 1 comment
Open
Labels
paredit Paredit and structural editing

Comments

@skylize
Copy link
Contributor

skylize commented Sep 12, 2022

I propose an (optional?) special case rule to block Paredit from removing any whitespace (or at least newlines) directly to the left of the cursor. Bonus if manually triggering format ignores the special case.


Why

Example cases ( | represents cursor, not pipe char.) :

(defn foo (|))
;; type backspace
;; ==>
(defn foo|)
(defn foo
  (|))
;; type backspace
;; ==>
(defn foo|)

My next action in these examples will be typing [ in place of an accidentally typed (. But whitespace gets collapsed, so instead of ( I must type Space> [ or Enter [.

The extra keystroke is of minimal importance. The problem here is the jarring movement of the cursor and loss of immediate context. This is especially disorienting in cases that collapse empty line(s).

Another example :

(let [fooooooooooooooooo {:a "a"}
      bar                [|]])
;; type backspace
;; ==>      
(let [fooooooooooooooooo {:a "a"}
      bar|])      

In this example the added keystrokes are important. I have already done extra work to carefully align the left bracket with the brace above it. Pressing Backspace wipes all that away. (Plus I have to use Space to fix it, because Calva hijacked Tab.)

@PEZ PEZ added the paredit Paredit and structural editing label Sep 12, 2022
@PEZ
Copy link
Collaborator

PEZ commented Sep 12, 2022

Thanks!

Iirc there is some code used by the backspace Paredit function that possibly can be put in use for this purpose as well. It might be a matter of recognizing the situation and skip post-edit formatting.

As for the bonus. If it is ”just” skipping post-edit, then we'll get the bonus for free. And if it is a matter of tweaking the formatting, it today considers if the formatting is happening as-you-type or on-demand, so this case can probably be handled there.

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

No branches or pull requests

2 participants