Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sp-kill-hybrid-sexp doesn't always remove empty lines #974

Open
edam opened this issue Apr 25, 2019 · 3 comments
Open

sp-kill-hybrid-sexp doesn't always remove empty lines #974

edam opened this issue Apr 25, 2019 · 3 comments

Comments

@edam
Copy link
Contributor

edam commented Apr 25, 2019

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

  • smartparens version: 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
@edam
Copy link
Contributor Author

edam commented Apr 25, 2019

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?

@Fuco1
Copy link
Owner

Fuco1 commented Apr 28, 2019

Yes that seems not to be correct. I think there might be some special behaviour in case the containing expression is completely empty.

@Fuco1 Fuco1 added this to Triage Mar 18, 2024
@Fuco1 Fuco1 moved this to To triage in Triage Mar 18, 2024
@Fuco1 Fuco1 moved this from To triage to Backlog in Triage Apr 3, 2024
@Kolmas225
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

3 participants