alexherbo2 / auto-pairs.kak

Auto-pairing of characters for Kakoune
https://kakoune.org
77 stars 18 forks source link

Critical bug with python: autopair remove stuff out of its scope ( ! ) #42

Closed sucrecacao closed 4 years ago

sucrecacao commented 4 years ago

how to repoduce:

Open a new python file: kak /tmp/foo.py paste the following:

def f():
    bar
    foo

But the cursor on the line of hello and A<ret> to insert on a new line between bar and foo. Type hello world . You should be in insert mode like so :

def f():
    bar
    hello world_
    foo

Now start deleting with backspace. Continue pressing backspace until the begining of the line.

expected behaviour

The line is deleted, the foo and bar line are unchanged

actual behaviour

Backspace act like backspace+delete, swallowing character on the right side of the cursor. It start by deleting the \n char. of the hello world line and then the content of the foo line.

alexherbo2 commented 4 years ago

Cannot reproduce. Have you prelude.kak up-to-date?

sucrecacao commented 4 years ago

yep, last commit 01f00761050cf9cbd92c018d3dc538ffe77a384f

I solved the issue by removing the auto-pair plugin, but maybe it's a mix of autopair and something else.

Do you have auto-expand ? I think this plugin changes tab for space, maybe auto-pair run on a hook on that

alexherbo2 commented 4 years ago

Can you investigate the cause?

sucrecacao commented 4 years ago

Not sure I have time/skills for that. It has to do with autopair removing character as far as I can investigate ^^

sucrecacao commented 4 years ago

I think I found: I had removed this line from the plugin:

@@ -24,7 +24,7 @@ provide-module auto-pairs %{
     map global insert <ret> '<a-;>: auto-pairs-insert-new-line<ret>'
     map global insert <space> '<a-;>: auto-pairs-insert-space<ret>'
     map global insert <backspace> '<a-;>: auto-pairs-delete-with-backspace<ret>'
-    map global insert <del> '<a-;>: auto-pairs-delete-with-delete<ret>'
+    # map global insert <del> '<a-;>: auto-pairs-delete-with-delete<ret>'
     # Update auto-pairs on option changes
     hook -group auto-pairs global WinSetOption auto_pairs=.* %{
       auto-pairs-save-settings

By deleting the comment it worked again. Does that make sense ? Because I though deleting a mapping would not affect other behaviour than when I press the given key.

I deleted this mapping because it very anoying when you want to type [ ] or any space between a pair. And I also don't like that auto-pair add another space on the other side when typing space.

sucrecacao commented 4 years ago

But great work otherwise :heart:

alexherbo2 commented 4 years ago

To you, Space, Backspace and Delete should be removed?

sucrecacao commented 4 years ago

Maybe it could be an option ?

I think they are used differently from user to user, and when one is used to a special workflow it can be annoying to have those extra behavior.

Out of curiosity, how would you do if you want just one parenthesis ? or a ( ) ( one space between two parenthesis ) ?

-- Securely sent with Tutanota. Get your own encrypted, ad-free mailbox: https://tutanota.com

Sep 12, 2020, 11:10 by notifications@github.com:

To you, > Space> , > Backspace> and > Delete> should be removed?

— You are receiving this because you authored the thread. Reply to this email directly, > view it on GitHub https://github.com/alexherbo2/auto-pairs.kak/issues/42#issuecomment-691451687> , or > unsubscribe https://github.com/notifications/unsubscribe-auth/ANKNYTXBOW4ZVHILFZJ4MVDSFM3I3ANCNFSM4QP2TAFA> .

alexherbo2 commented 4 years ago

I prefer to remove them if they are annoying.

How about Return?

sucrecacao commented 4 years ago

Return is pretty handy :)

alexherbo2 commented 4 years ago

Can you detail me when you are typing (▌), inserting a space and do not want (␣▌␣).

taupiqueur = {▌}
taupiqueur = { ▌ }
taupiqueur = { index: 50, name: "Diglett"▌ }
sucrecacao commented 4 years ago

As I said I don't remember exactly for which case I had removed the the delete behaviour`, I think it was while writting python.

But an example that pop in my head right now is when doing markdown todo list:

 - [X] bar
 - [ ] foo
alexherbo2 commented 4 years ago

Delete but not Backspace or Space?