Fuco1 / smartparens

Minor mode for Emacs that deals with parens pairs and tries to be smart about it.
GNU General Public License v3.0
1.8k stars 193 forks source link

Wrong behavior in C-like modes (at least with default configuration) #1166

Open doublep opened 12 months ago

doublep commented 12 months ago

Default behavior of sp-forward-slurp-sexp and related functions in C-like modes is wrong, at least unless you apply special configuration to fix it. In comparison, everything works correctly out-of-the-box if you open a JavaScript file, despite JS having a pretty C-like or Java-like syntax.

Steps to reproduce the problem

Open a file with text

foo.bar (42);

in a C-like mode (extensions .c, .cpp, .java and likely others associated with C-like modes).

Type ( then M-x sp-forward-slurp-sexp RET several times (or whatever keybinding you use for that).

Expected behavior

After (:

()foo.bar (42);

After consecutive slurping:

(foo).bar (42);
(foo.bar) (42);
(foo.bar (42));

Actual behavior

()foo.bar (42);     // As expected
(foo.)bar (42);     // Wrong
(foo.bar) (42);     // As expected
(foo.bar (42);)     // Wrong

Environment & version information