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

Support of regional undo history #77

Open
arnobl opened this issue Oct 22, 2022 · 0 comments
Open

Support of regional undo history #77

arnobl opened this issue Oct 22, 2022 · 0 comments

Comments

@arnobl
Copy link
Member

arnobl commented Oct 22, 2022

Get the history related to a given object, instead of having a unique global history

Use cases:

  • drawing app: select an object. Its history is extracted from the global one to be then display
  • text editor: from a given caret location, the history related to the position (more or less) is extracted from the global one to be then display

This is a specific case of selective undo as undoing the latest command of a given object may mean cherry-picking this command from the global one.

They are various corner scenarios / challenges:

Composite commands

Illustrative example with a drawing app: the user moves 3 shapes. One command that moves those 3 shapes is produced. The user selects one of those three shapes. Its history is displayed. The user undoes the move command => how to undoes only part of the initial command? (part of the solution: composite pattern)

Producing regional histories

How to extract from a global history a history specific to a given object? Part of the solution: an undoable command has a method that returns the associated object. By default returns undefined or [].

First example with the drawing app. The user draws several shapes and then selects one of them. The regional history asks the global one commands which associated object is the data object corresponding to the model of the selected shape.

Second example with a text editor. The user types some text: three successive commands "Supporting" "the" "regional undo".
Then the user selects the "the" text and put it in red. Finally, the user put the caret on the "the" word. The commands related to the given caret position form the regional undo.

Managing regional conflicts

Using the previous example of the text editor, the user undoes the command that produced the "the" word. What to do with the command that put this word in red? Part of the solution: identify command that creates objects, so that cancelling such commands removes the related command from the global history.

Second example using the text example. The user selects the whole text at put it in green. Then the user undoes the creation of the word "the". How to manage the green color command (composite command?)?

Redoing cherry-picked creation command

Using the previous example of the text editor. The user now wants to redo the creation of the word "the" (so that it includes the re-integration of the color command). How to access regional history of removed objects?

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

1 participant