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

Cursor jumps to start of line when typing curly brace in JSX property #81

Closed
dentafrice opened this Issue Sep 2, 2018 · 13 comments

Comments

10 participants
@dentafrice

dentafrice commented Sep 2, 2018

Hi!

Thanks for your work on rjsx-mode.

I'm encountering an issue adding properties to an element. Curly braces seem to trigger a re-indent of the line and cause the cursor to jump to the beginning of the line.

I've recorded a few different examples here.

I'm experiencing this issue in Spacemacs, but I've tried to reproduce this in as bare of an emacs configuration as I can. This is my first time filing an issue with an emacs package, please let me know if there's any additional information that I can provide or if I'm doing something stupid here.

Zero configuration

rjsx-mode

Opening a curly brace de-indents line, closing a curly re-indents (incorrectly to 2 spaces) and places cursor at the beginning of line.

simplescreenrecorder-2018-09-02_13 48 55

js2-jsx-mode:

Opening a curly brace de-indents the line, closing doesn't fix it. Cursor stays in place.

simplescreenrecorder-2018-09-02_13 48 17

Fixing indent level

I noticed that by default js-indent-level is 4, and sgml-basic-offset is 2. I added the following code to init.el to make them equal.

(setq-default
 js-indent-level 4
 sgml-basic-offset 4)

This seems to fix the indention issues completely in both modes, but rjsx-mode's cursor still jumps to the beginning of the line.

rjsx-mode

simplescreenrecorder-2018-09-02_13 51 31

js2-jsx-mode

simplescreenrecorder-2018-09-02_13 51 02

init.el

(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))

(setq package-list
    '(rjsx-mode))

; activate all the packages
(package-initialize)

; fetch the list of packages available
(unless package-archive-contents
  (package-refresh-contents))

; install the missing packages
(dolist (package package-list)
  (unless (package-installed-p package)
    (package-install package)))

Versions

GNU Emacs 26.1
rjsx-mode: 20180823.1645
js2-mode: 20180724.801

@dentafrice

This comment has been minimized.

Show comment
Hide comment
@dentafrice

dentafrice Sep 3, 2018

After additional testing, I think this issue may have been introduced in eae8137.

I'm unable to reproduce this issue on commits prior to that change. For example, running 3f7efda:

simplescreenrecorder-2018-09-02_18 08 37

dentafrice commented Sep 3, 2018

After additional testing, I think this issue may have been introduced in eae8137.

I'm unable to reproduce this issue on commits prior to that change. For example, running 3f7efda:

simplescreenrecorder-2018-09-02_18 08 37

@felipeochoa

This comment has been minimized.

Show comment
Hide comment
@felipeochoa

felipeochoa Sep 3, 2018

Owner

Thanks for bisecting. I'm having this issue with the new indentation code, so I'm assuming you have some sort of electric mode (e.g., smartparens) that tries to reindent when you type a curly brace.

Owner

felipeochoa commented Sep 3, 2018

Thanks for bisecting. I'm having this issue with the new indentation code, so I'm assuming you have some sort of electric mode (e.g., smartparens) that tries to reindent when you type a curly brace.

@qhuyduong

This comment has been minimized.

Show comment
Hide comment
@qhuyduong

qhuyduong Sep 3, 2018

I'm facing the same issue. Look forward to seeing the fix soon.

qhuyduong commented Sep 3, 2018

I'm facing the same issue. Look forward to seeing the fix soon.

@felipeochoa

This comment has been minimized.

Show comment
Hide comment
@felipeochoa

felipeochoa Sep 3, 2018

Owner

If you want to see it sooner, it's probably just a fix on rjsx-indent-line. PRs welcome 😉

Owner

felipeochoa commented Sep 3, 2018

If you want to see it sooner, it's probably just a fix on rjsx-indent-line. PRs welcome 😉

@dentafrice

This comment has been minimized.

Show comment
Hide comment
@dentafrice

dentafrice Sep 3, 2018

so I'm assuming you have some sort of electric mode (e.g., smartparens) that tries to reindent when you type a curly brace.

Unless I'm misunderstanding, I'm reproducing this on a clean emacs installation with just js2-mode and rjsx-mode installed.

I don't think there's any external mode/package interference going on here.

dentafrice commented Sep 3, 2018

so I'm assuming you have some sort of electric mode (e.g., smartparens) that tries to reindent when you type a curly brace.

Unless I'm misunderstanding, I'm reproducing this on a clean emacs installation with just js2-mode and rjsx-mode installed.

I don't think there's any external mode/package interference going on here.

@danielmt

This comment has been minimized.

Show comment
Hide comment
@danielmt

danielmt Sep 3, 2018

It's happening typing dots too, on jsx files. It jumps back to the start of the line, typing dots anywhere (even on just text within tags).

Imgur Image

danielmt commented Sep 3, 2018

It's happening typing dots too, on jsx files. It jumps back to the start of the line, typing dots anywhere (even on just text within tags).

Imgur Image

@qhuyduong

This comment has been minimized.

Show comment
Hide comment
@qhuyduong

qhuyduong Sep 3, 2018

@felipeochoa I have opened a pull request for this issue. Please check.

qhuyduong commented Sep 3, 2018

@felipeochoa I have opened a pull request for this issue. Please check.

@jinhale

This comment has been minimized.

Show comment
Hide comment
@jinhale

jinhale Sep 6, 2018

Typing a comma will do this as well as long as the comma separates items of an array in an attribute's properties.

jinhale commented Sep 6, 2018

Typing a comma will do this as well as long as the comma separates items of an array in an attribute's properties.

@gustavo-depaula

This comment has been minimized.

Show comment
Hide comment
@gustavo-depaula

gustavo-depaula Sep 9, 2018

Suffering with this problem as well! 👍 Using doom-emacs here

gustavo-depaula commented Sep 9, 2018

Suffering with this problem as well! 👍 Using doom-emacs here

@qleguennec

This comment has been minimized.

Show comment
Hide comment
@qleguennec

qleguennec Sep 12, 2018

Same issue here, using doom-emacs

qleguennec commented Sep 12, 2018

Same issue here, using doom-emacs

@trev-dev

This comment has been minimized.

Show comment
Hide comment
@trev-dev

trev-dev Sep 14, 2018

@felipeochoa Thank you for the PR!!

trev-dev commented Sep 14, 2018

@felipeochoa Thank you for the PR!!

@DoMiNeLa10

This comment has been minimized.

Show comment
Hide comment
@DoMiNeLa10

DoMiNeLa10 Sep 17, 2018

I've been experiencing this problem as well recently, and I'm glad it got resolved before I got to updating rjsx-mode.

DoMiNeLa10 commented Sep 17, 2018

I've been experiencing this problem as well recently, and I'm glad it got resolved before I got to updating rjsx-mode.

@deviantfero

This comment has been minimized.

Show comment
Hide comment
@deviantfero

deviantfero Sep 18, 2018

I was having this issue as well, it has been resolved, just stopping by to say thanks for such a wonderful package!

deviantfero commented Sep 18, 2018

I was having this issue as well, it has been resolved, just stopping by to say thanks for such a wonderful package!

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