sp-kill-hybrid-sexp doesn't always remove empty lines
sp-kill-hybrid-sexp doesn't always remove empty lines if there are only empty lines between point at the close paren.
E.g.: (point is |)
foo() {
|
}
In this state, sp-kill-hybrid-sexp has no effect at all. Whereas it should produce:
foo() {
|
}
To illustrate this point, if we started with:
foo() {
|
something();
}
then sp-kill-hybrid-sexp works as expected and produces:
foo() {
|
something();
}
Somehow, the lack of something(); before the close paren prevents sp-kill-hybrid-sexp from working!
Environment & version information
-
smartparensversion: 1.11.0 - Active major-mode: c-mode (or js-mode)
- Emacs version: GNU Emacs 26.1 (build 2, x86_64pc-linux-gnu, GTK+ Version 3.24.4) of 2019-02-03, modified by Debian
- OS: Debian "buster" x86_64 GNU/Linux
The underlying problem appears to be that in this case:
foo() {
|
x
}
sp-get-hybrid-sexp returns (:beg 9 :end 13), where point is 13 and at the end of the line. But in this case:
foo() {
|
}
sp-get-hybrid-sexp returns (:beg 9 :end 9), which is at the beginning of the line that point is on.
Which is the correct behaviour? The comment for sp-get-hybrid-sexp says it returns
the smallest balanced region containing the point while not expanding further than the current line.
So does that mean that the second case is incorrect, since a region with :end 9 does not contain point?
Yes that seems not to be correct. I think there might be some special behaviour in case the containing expression is completely empty.
This bug still exist in some form right now. When the cursor is right at the empty last line of an sexp the line will not get killed and stayed the same.
foo() {
...
|
}
#975 will fix this case