atom-vim-mode-plus icon indicating copy to clipboard operation
atom-vim-mode-plus copied to clipboard

Undo is not working properly jsx syntax is selected

Open neliojrr opened this issue 9 years ago • 5 comments

Issue: When I type undo it always left a code snippet without undo. Usually is a ending tag(e.g. </div>.

How to reproduce:

  • Edit a .js file
  • Set the syntax to JSX
  • Write down some html code
  • Type undo
  • Does not work properly

GIF: atom_issue

It's a bit specific. When I'm editing html files it doesn't happen. But maybe it's happening with some other file types.

  • Atom version 1.16.0
  • vim-mode-plus version: 0.91.0
  • Your OS: macOS Sierra 10.12.4
  • You disabled vim-mode? Yes

neliojrr avatar May 08 '17 10:05 neliojrr

  • What the language-plugin for JavaScript (JSX). There are several packages.
  • Do you need some snippet expansion to reproduce issue?
  • Issue is 100% reproducable?
  • When you could reproduce issue, can you correctly undo the change by normal core:undo (cmd-z) ?

To reproduce issue in my side, I need precise package name you are using for JSX, complete procedure including keystroke.

Thanks.

t9md avatar May 08 '17 12:05 t9md

OK I think I could repro.

  • Install react package.
  • Grammar Selector: Show, then select JavaScript( JSX ).
  • type i<div> then escape. At this point, text is <div></div> Since when I type >, closing tag is auto inserted.
  • u to undo. now tex is
    • </div>, It should be empty. u should revert to the text state BEFORE entering insert-mode.

My impression for this issue is maybe React plugin do something special, I'll investigate but not sure fixable by vmp-side.

t9md avatar May 08 '17 12:05 t9md

Hi, found the cause.

This line of atom-react package.

editor.insertText('</' + tagName + '>', {undo: 'skip'})

https://github.com/orktes/atom-react/blame/master/lib/atom-react.coffee#L247

Inserting text with the options {undo: 'skip'}, means, "skip this insertion when undoing, in other word don't maintain buffer change history for this time mutation". ~~I 'm not sure why they explicitly setting this option.~~ (understood "why" after investigated atom-react) I disabled in locally and confirmed the u(undo) works as expected. If some mutation skips undo history, nothing I can do by my vmp side. I'll open issue on ato-react, but I'm not atom-react user. If you need, pls add follow-up commment on that issue.

t9md avatar May 08 '17 13:05 t9md

sent PR. Nothing I can do after all.

t9md avatar May 08 '17 13:05 t9md

Thank you! I really appreciate that! I'll follow the issue that you opened on atom. 👍

neliojrr avatar May 08 '17 18:05 neliojrr