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

Formatting and undo (u) not behaving correctly #1737

Open
ksrb opened this issue May 22, 2017 · 9 comments
Open

Formatting and undo (u) not behaving correctly #1737

ksrb opened this issue May 22, 2017 · 9 comments

Comments

@ksrb
Copy link

ksrb commented May 22, 2017

  • Click thumbs-up 👍 on this issue if you want it!
  • Click confused 😕 on this issue if not having it makes VSCodeVim unusable.

The VSCodeVim team prioritizes issues based on reaction count.


BUG REPORT:

Environment:

  • VSCode Version: Version 1.12.2 (1.12.2)
  • VsCodeVim Version: 0.7.1
  • OS: Mac OSX 10.11.6 (15G1421)

What happened:

  1. git clone -b gh-pages https://github.com/dhg/Skeleton
  2. Open index.html
  3. shift+alt+f/editor.action.formatDocument
  4. u

Actual:
Nothing happens/code doesn't 'un-format'

Expected:
Code should 'un-format'/go back to original format

@ksrb
Copy link
Author

ksrb commented May 22, 2017

Sorry didn't really follow the bug format as I'm unsure how to even word the bug.

Instead of cloning the Skeleton repo you can open any sufficiently complicated html page and it should also have the same bug.

Also cmd + z does 'un-format' the document but if you press u first cmd + z doesn't work.

@Chillee
Copy link
Member

Chillee commented May 22, 2017

What if you press u and then hold down ctrl z for a while?

@ksrb
Copy link
Author

ksrb commented May 22, 2017

Nothing happens 😞.

@Chillee
Copy link
Member

Chillee commented May 22, 2017

I'm fairly confident actually that if you hold down ctrl-z for long enough, it'll undo all the changes...

It's just that the our "undo" action doesn't undo everything, and it leads to a bunch more undo steps that ctrl-z is going through. At least on a smaller document (2000 lines or so, not very dense), holding down ctrl-z seems to do the trick...

A rewrite to our undo functionality is currently planned (whether it'll be by leveraging Neovim or Vscode's undo API, we're not sure): #1727

@ksrb
Copy link
Author

ksrb commented May 22, 2017

Hmm I'm pretty sure holding ctrl/cmd + z doesn't work.

may-22-2017 15-15-42

I pressed cmd + z a couple of dozen extra times after that I just figured that it would be redundant after the first 10 😄.

Welp if you're sure this is going to fixed by #1727 then I guess I'll just wait :|.

@Chillee
Copy link
Member

Chillee commented May 22, 2017

On the same file, it seems to work for me.

tmp
After calling the command, I press u a couple of times, and then I start holding down ctrl z.

This issue (#1589) has the same root cause (I think), but it'll be solved due to neovim integration.

The issue you're talking about needs to be fixed by fixing up undo somehow.

@ksrb
Copy link
Author

ksrb commented May 22, 2017

Oh okay thanks I wasn't holding down cmd + z long enough 😝. Well I guess since you guys are aware of this issue I'll close this?

@ksrb ksrb closed this as completed May 22, 2017
@Chillee
Copy link
Member

Chillee commented May 22, 2017

@ksrb Haha well it's definitely a bug and really bad on our part :P. I think we should keep it open for now, as there isn't another issue exactly tracking this. (The other one I linked is fixed by #1725)

@Chillee Chillee reopened this May 22, 2017
@J-Fields J-Fields changed the title Formatting and undo (u) not behaving correctly Formatting and undo (u) not behaving correctly Oct 15, 2021
@larslue
Copy link

larslue commented Nov 23, 2023

Hi, this is still an issue for me. The Black formatter for Python does not support "Format selection", but only "Format document"
image

So I resort to using "Format document", or Ctrl + Shift + I from the command panel. After formatting, I need to be aware to not press u by accident since the undo operation likely breaks the document.

I assume this bug is caused by the fact that Ctrl + Shift + I is not piped through the Vim plugin, so the plugin is not aware of the formatting action.

Would it be possible to add a keyboard shortcut to the Vim plugin to "Format document". e.g. =ie or similar? And document it extensively.

Would this fix the issue?

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

3 participants