pears.nvim icon indicating copy to clipboard operation
pears.nvim copied to clipboard

Extraneous closing bracket when returning from normal mode

Open kflak opened this issue 5 years ago • 8 comments

Hi,

Thanks for a great plugin! I am not sure if this is a bug or a feature, but when I write ( I get this output (|) as expected. And if I keep typing inside the brackets and then hit ) the cursor hops to after the closing bracket.

However: when I am inside the bracket and leave insert mode, then come back to insert mode and type ) I end up with )|).

Is there a way to avoid this?

kflak avatar Apr 22 '21 08:04 kflak

I would like to avoid this aswell. :~)

salkin-mada avatar Apr 22 '21 08:04 salkin-mada

It happened to me a few times when I did pasting via p

You can also do this trick. But I guess this is rather related to the wildtag matching.

  • <div<| ooops
  • <div|
  • <div>|</>

theHamsta avatar Apr 22 '21 09:04 theHamsta

Hopping past the closer is a feature and is expected. I'm gonna make that more configurable in the future.

Now when leaving insert mode, all contexts of inserted pairs are removed. When entering insert mode again we can't hop past expanded pairs because we no longer know about ones. This is an intentional design decision. Pears doesn't keep track of existing pairs in the file, only ones entered during insert mode. Once it's left insert mode it doesn't care anymore. I've had to many issues with pair plugins trying to be to smart and move past characters when I didn't want it to. This is what drove this design decision.

steelsojka avatar Apr 22 '21 12:04 steelsojka

Also, there may be some sort of way to do this in the future, but it is not high on the priority list.

steelsojka avatar Apr 22 '21 12:04 steelsojka

Fair enough :-) If this is expected behavior I'll learn how to get used to it. I'd keep this issue open, though, in case you find a good way of configuring this.

kflak avatar Apr 22 '21 12:04 kflak

@kflak I eventually want to make it an opt in feature at some point. I don't like it ;) but I know a lot of people probably would opt into it.

steelsojka avatar Apr 22 '21 12:04 steelsojka

Currently I certainly would, but who knows, maybe a bit of forced weening would make me come to the dark side as well...

kflak avatar Apr 22 '21 12:04 kflak

I'd like to see support for this as well. :smiley: Currently it's a bit tricky to use pears in combination with for example code completion, as navigating pmenu results require you to exit insert mode, thus resetting pears' state.

yorickpeterse avatar May 18 '21 14:05 yorickpeterse