alexherbo2 / auto-pairs.kak

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

Type "through" closing pair #53

Closed jaredramirez closed 1 year ago

jaredramirez commented 3 years ago

Hey, thanks for the great plugin!

I'm new to using auto-pairs, so I find myself often typing [] because I forget that auto-pairs will add the closing pair for me. However, when I do this, I end up with []], one closing pair for the one inserted by auto-pairs and another for the one that I type. It would be great if it was possible to type "through" the closing pair if it's already there.

I think in addition to me forgetting to use auto-pairs and typing the extra ], there are other cases this behavior is helpful. For example, take the following Elm code:

html [] [ span [] [ text "hello" ] ]

Each time I type [] and want to continue typing past the closing pair with auto-pairs enabled, I need to do the following keystrokes:

[ -- Create the bracket (and auto-pairs inserts the closing one)
<esc> -- exit insert mode
l -- move to the right
i -- go back to insert mode
... -- continue typing

However, if I could type "through" the closing bracket I could do:

[ -- Create the bracket (and auto-pairs inserts the closing one)
] -- Don't actually insert the "]", but just move past that character
... -- continue typing, but now I don't need to leave insert mode at all!

I think that this is something VSCode does too.

I have no idea the technical hurdles to achieve this, but it would be cool if it was possible!

BrianHicks commented 3 years ago

It used to do this! I was just coming here to open a similar issue after an upgrade. @alexherbo2 is this a bug or on-purpose?

alexherbo2 commented 3 years ago

It does work for me.

https://user-images.githubusercontent.com/5666362/139112013-7e5e3b71-4589-463e-8ae8-86099c7fcb9d.mp4

jaredramirez commented 3 years ago

Hmm, odd. Here's a quick vid of what I'm seeing:

https://user-images.githubusercontent.com/8095741/139465527-4131871f-152d-4bf7-893c-0b7bf1018722.mov

This is with the latest master branch

jcuffe commented 2 years ago

I think that this is due to us not having a recent enough version of Kakoune, @jaredramirez. I tracked it down to the decrement-inserted-pairs-count, here's what I see when I try to use the -remove flag on set-option:

image

Relevant clippy:

image

edit: Removing system installed version and compiling from source fixed this issue for me! You can probably verify it'll work by checking the help text for :set-option for the -remove flag:

image

maximbaz commented 1 year ago

Given that a year has passed, a more recent kakoune version has probably reached the repos, and you are no longer experiencing this issue, closing :+1: