Aerilius / sketchup-console-plus

A better Ruby Console and IDE for integrated development in SketchUp.
MIT License
42 stars 17 forks source link

Wrap the code inside an operation #16

Closed gustavo-hms closed 7 years ago

gustavo-hms commented 7 years ago

The Ruby Code Editor (http://extensions.sketchup.com/en/content/ruby-code-editor) has an option (its a default one actually) to wrap the entire edited code between a start_operation and a commit_operation. This way one can run the code in the editor and undo it with a single undo.

It would be nice if this extension could also provide this option. It would improve its usability.

Aerilius commented 7 years ago

This feature has also been here for a very long time (console.rb#L205), but it is currently not exposed in the UI because it needs to be rethought:

gustavo-hms commented 7 years ago

It is indeed useful. Suppose I run a code that does, say, 1000 copies of a group and put them in a grid. If I then realise that the gap between them is just too small, I need to undo the operations, adjust the parameters and then rerun the code. But undoing 2000 operations is very tedious, if not unfeasible.

Regarding the representation of the operation, I don't have the perfect answer, but maybe we don't need to find a detailed representation; maybe something like “Undo Console+ code run” or “Undo Console+ operation” is good enough.

Aerilius commented 7 years ago

An issue in the previous version was that someone using the console is likely to emit many commands (some of which even don't modify the model). When navigating the undo stack backwards they should be distinguishable. I had solved it by adding a counter in the operation name, which was not very meaningful and not elegant in the code. It is a feature and not a core responsibility of the console, so I need to figure out how to best implement it using the feature system and keep the core console class as lean as possible (to avoid bloat).