smartparens icon indicating copy to clipboard operation
smartparens copied to clipboard

Inserting ) with a highlighted pair selection visible jumps to enclosing ) instead

Open wasamasa opened this issue 8 years ago • 11 comments

Video.

I can reproduce this with sp-cancel-autoskip-on-backward-movement set to nil in emacs -Q.

wasamasa avatar Dec 07 '15 11:12 wasamasa

I don't understand how to reproduce this.

I type ( then the text, then I go back then I hit ( then I hit ) and the result is what I expected

(foo
 ()| bar
 baz)

Fuco1 avatar Dec 07 '15 17:12 Fuco1

This isn't quite right. I type the list, move point to the start of the second item, insert a paren pair, delete the closing paren, move point to the end of the second item, then type a closing paren. I expect a closing paren to be inserted (like with every self-inserting key). Instead point moves to the outer closing paren and the highlighting stops. If I go back again and attempt inserting the closing paren another time, it works. Almost as if Smartparens were in a special state while the area between delimiters is highlighted...

Now with less prose:

Typing the list:

(foo
 bar
 baz)|

Positioning point at the start of the second list item:

(foo
|bar
 baz)

Typing ( results in a pair:

(foo
 (|)bar
 baz)

I delete the ) with DEL:

(foo
 (|bar
 baz)

Positioning point at the end of the second list item:

(foo
 (bar|
 baz)

Typing ) doesn't insert anything and moves point to the end instead:

(foo
 (bar
 baz)|

Positioning point at the start of the second list item (again):

(foo
 |(bar
 baz)

Positioning point at the end of the second list item (again):

(foo
 (bar|
 baz)

Now typing ) works as expected:

(foo
 (bar)|
 baz)

wasamasa avatar Dec 07 '15 19:12 wasamasa

What does DEL call?

Fuco1 avatar Dec 08 '15 17:12 Fuco1

That it jumps out is expected, SP doesn't parse the entire buffer to figure out if you are not balanced. As soon as it finds a working pair it jumps out in strict mode. In non-strict mode it inserts the closing thing.

Fuco1 avatar Dec 08 '15 17:12 Fuco1

The thing is that I'm not using strict mode at all, so this behaviour surprises me. Even more so when it works as expected after canceling the pair content highlighting. DEL calls delete-forward-char.

wasamasa avatar Dec 08 '15 17:12 wasamasa

What is sp-autoskip-closing-pair set to? I can't repro this so far.

Fuco1 avatar Dec 08 '15 17:12 Fuco1

It's set to always-end.

wasamasa avatar Dec 08 '15 17:12 wasamasa

Perhaps all I need to do is updating Smartparens...

wasamasa avatar Dec 08 '15 17:12 wasamasa

I've updated Smartparens and can still reproduce this ._.

wasamasa avatar Dec 09 '15 09:12 wasamasa

When the pair is "active" and you type the closing delimiter it jumps out, so yes it is in a special state.

What should happen is the state should be cancelled when you enter another insertion... probably.

Fuco1 avatar Dec 11 '15 17:12 Fuco1

With strict mode disabled and (setq-local sp-autoskip-closing-pair 'always-end) it now inserts the closing paren at the first insertion properly. Can you confirm this?

Fuco1 avatar Oct 20 '16 12:10 Fuco1