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

Allow Undo of complete macro (not just last action) #48

Closed
yaagma opened this issue Apr 30, 2019 · 11 comments
Closed

Allow Undo of complete macro (not just last action) #48

yaagma opened this issue Apr 30, 2019 · 11 comments

Comments

@yaagma
Copy link

yaagma commented Apr 30, 2019

The extension is GREAT. But when using Undo (Ctrl+Z), I'd like to be able to undo all the actions of the macro; not just the last one.

For example, in this macro, only "editor.action.removeCommentLine" is undone.

 "commentDown": [
            "editor.action.addCommentLine",
            "editor.action.copyLinesDownAction",
            "editor.action.removeCommentLine"
        ]

To Undo a macro, I have to type "Ctrl+Z" as many times as editor actions it has.

Thanks

@ctf0
Copy link

ctf0 commented May 11, 2019

the ext simply runs commands in sequence, it doesnt add any extra side operations to track the changes made.

what u need is something like full undo or undo all similar to https://github.com/shagabutdinov/sublime-full-undo

@yaagma
Copy link
Author

yaagma commented May 11, 2019

what u need is something like full undo or undo all similar to https://github.com/shagabutdinov/sublime-full-undo

Not exactly. That plugin seems to undo every change in the file, not just the changes in the last executed macro.

What I'm looking for is something like:

 "commentDown": [
            "START_UNDO_CONTEXT",       // <<<<<<<<<<<<<<<<<<<<<<<<
            "editor.action.addCommentLine",
            "editor.action.copyLinesDownAction",
            "editor.action.removeCommentLine"
            "END_UNDO_CONTEXT",       // <<<<<<<<<<<<<<<<<<<<<<<<
        ]

So, if I press Ctrl+Z, the complete macro in undone (but no more).
I don't know if that is possible.

Thanks

@ctf0
Copy link

ctf0 commented May 11, 2019

mmmm, maybe create another custom command like #13 where u put a command u want to run and the one you want to execute accordingly ex.

"macros": {
  "undoMacroChanges": [
    {"command": "undo", "args": {"command": "commentDown"}},
  ]
}

so now when u execute undoMacroChanges the function will run the undo command times the number of the commentDown array count

@yaagma
Copy link
Author

yaagma commented May 11, 2019

mmmm, maybe create another custom command like #13 where u put a command u want to run and the one you want to execute accordingly ex.

"macros": {
  "undoMacroChanges": [
    {"command": "undo", "args": {"command": "commentDown"}},
  ]
}

so now when u execute undoMacroChanges the function will run the undo command times the number of the commentDown array count

It could be, but I think it would be more usable if you could somehow use Ctrl+z instead of a new command.
If I understand this solution, when you press a keybinding to do a command and you want to undo its effect, you must stop and answer yourself ¿Was this a simple command or was it a macro? ¿Should I use Ctr+z or should I use "undoMacroChanges" command?

I'd like that, when I want to undo a keybinding effect, native commands and macros behave the same way (when using Ctrl+Z)

Sorry. English it's not my native language.

Thanks

@ctf0
Copy link

ctf0 commented May 11, 2019

@tberghuis
Copy link

@ctf0 Your fork works great, however i can't raise issues on your repo

@ctf0
Copy link

ctf0 commented Jun 2, 2019

@tberghuis i didn't notice it was off, done

@yaagma
Copy link
Author

yaagma commented Jun 8, 2019

try https://marketplace.visualstudio.com/items?itemName=ctf0.macros

There is no difference. Ctrl+z behaves the same way: only last action is undone (not the whole macro).
¿What should I try?

Thanks

@ctf0
Copy link

ctf0 commented Jun 8, 2019

the ctrl+z wont work as u expect because macros are not a native command, what u need is to create another command that counter the effect of the ran macro ex.https://github.com/ctf0/macros#new

@yaagma
Copy link
Author

yaagma commented Jun 9, 2019

Ok. Just to confirm: so for EVERY macro M I'd want to undo I should create another macro undoM and assign it a DIFFERENT keybinding, isn't it?

It would be awesome that vs code would allow to interact with the undo manager to insert some form of composite action (composed by all the macro actions) and then it could handle this situation automatically for us.

Thanks for your work.

@ctf0
Copy link

ctf0 commented Jun 9, 2019

Ok. Just to confirm: so for EVERY macro M I'd want to undo I should create another macro undoM and assign it a DIFFERENT keybinding, isn't it?

correct

@yaagma yaagma closed this as completed Feb 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants