cursive-ide / cursive

Cursive: The IDE for beautiful Clojure code
574 stars 7 forks source link

Ctrl+Backspace with Paredit can delete a single parenthesis, which unbalances parentheses. #2884

Open matj1 opened 3 months ago

matj1 commented 3 months ago

If I use Cursive With Paredit, I can delete a single parethesis (right or left) with Ctrl+Backspace, which unbalances parentheses. In fact, Ctrl+Backspace deletes all consecutive parentheses just before the cursor. An additional problem is that, when it happens, I can't type the parenthesis to put it back because typing a left parenthesis inserts both parentheses, and typing a right parenthesis does nothing.

Deleting a single right parenthesis can be seen in the following recording.

Deleting a parenthesis

Expected behavior

I expect that Ctrl+Backspace would not delete the parentheses, but it would do this:

That is consistent with how Backspace works currently and with how Ctrl modifies the action to work on words instead of characters (IntelliJ Idea considers consecutive parentheses a word).

Example

With | representing the cursor, consider this situation:

(((( thing ))))|

Pressing Ctrl+Backspace is supposed to result in this situation:

(((( thing |))))

Also consider this situation (with a space between the left parentheses):

(( ((|))))

Pressing Ctrl+Backspace is supposed to result in this situation:

(( |))

System information

This happens if I have all plugins in IntelliJ Idea except Cursive disabled.

Cursive version: 1.13.1-2023.3

IntelliJ IDEA 2023.3.4 (Ultimate Edition)
Build #IU-233.14475.28, built on February 13, 2024
Runtime version: 17.0.10+1-b1087.17 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 6.1.77-2-manjaro
GC: G1 Young Generation, G1 Old Generation
Current Desktop: GNOME

rachbowyer commented 3 weeks ago

Just signal boosting this issue as I saw a similar ticket was raised 7 years ago so it is clearly not a high priority!

The goal of Paredit mode is to ensure that parenthesis are created in pairs so the ability to accidentally delete a single parenthesis is a significant problem for people who use word delete frequently.

To work around it I have mapped word delete forward to kill sexp but there is no kill sexp backward command. If this were added, then people could also map word delete backwards and the problem would be solved.

Alternatively, if a component API was added to Cursive then it would be possible to self-serve without needing to open source the entire project. At the moment though, Cursive users have no way forward.