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

In js2-mode, killing a line right before an expression breaks next line's indentation #696

Closed
davazp opened this issue Jan 22, 2017 · 6 comments

Comments

@davazp
Copy link

davazp commented Jan 22, 2017

The probem happens with js2-version 1.8.5 and smarparents from melpa: smartparens-20170104.410. I tried with Emacs 25.1 and no extra configuration besides js2-mode and smartparens.

To reproduce it:

function f () {
  <|>
  return 42;  // 2 spaces of indentation
}

After C-k, I get:

function f () {
<|> return 42;  // 1 space of indentation, point at the beginning of the line
}
@davazp
Copy link
Author

davazp commented Jan 22, 2017

As a workaround, I defined the following advice to get it as with the other modes:

  ;; Fix weird behaviour in js2-mode when we kill an empty line right
  ;; before an expression.
  (defun davazp/reindent-after-sp-kill-hybrid-sexp (&rest args)
    (when (eq major-mode 'js2-mode)
      (indent-for-tab-command)))
  (advice-add 'sp-kill-hybrid-sexp :after #'davazp/reindent-after-sp-kill-hybrid-sexp)

@davazp
Copy link
Author

davazp commented Jan 22, 2017

I looked at the problem, it seems to be in the sp--cleanup-after-kill function, but it looks intentional:

(unless (memq major-mode sp-no-reindent-after-kill-modes)
   ...

and js2-mode is listed in sp-no-reindent-after-kill-modes. Why is that?

@Fuco1
Copy link
Owner

Fuco1 commented Jan 22, 2017

To be honest I don't remember :/ Maybe it was a hack for some earlier version when things were broken.

Would you mind removing it from the list and test to see if it works or not?

@davazp
Copy link
Author

davazp commented Jan 22, 2017

Sure 👍 . It seems to work, at least in that simple case, but I will try for the next days to see if it breaks with other code.

@davazp
Copy link
Author

davazp commented Jan 30, 2017

I have used it this week and I cannot find any issue related to it.

Maybe somebody else can also have a look?

@Fuco1
Copy link
Owner

Fuco1 commented Jan 30, 2017

I'll look at the git blame output to find some context but I think it will be safe to remove. Thanks for reporting back!

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

No branches or pull requests

2 participants