Skip to content

[CLOSED] Specify edit origin for color editor widgets in order to batch undos #2645

@core-ai-bot

Description

@core-ai-bot

Issue by njx
Sunday Feb 03, 2013 at 23:13 GMT
Originally opened as adobe/brackets#2790


Fixes #2721.@peterflynn -- could you look at this one?

This takes advantage of the newly-exposed "origin" parameter to replaceRange() in CodeMirror. For each color editor, we create a unique origin string. This makes it so that all consecutive edits from a given color editor are batched into a single undo. This is slightly different from our v2 behavior, where the edits would only be batched if they were close together in time. We could implement that heuristic instead, but batching all edits from a given editor together seems to make sense as well, and is more predictable. (Of course, if there are intervening edits elsewhere in the document, they will interrupt the undo batching, as you would expect.)

Note that the change to Editor._applyChanges() isn't actually necessary for this bug fix and probably won't have any effect in the codebase today, but it seems to make sense semantically (i.e., if undos are batched in the underlying document, they should be batched in the synchronized editor, and vice versa). That issue should go away anyway when we switch to CM's own doc/view separation implementation.


njx included the following code: https://github.com/adobe/brackets/pull/2790/commits

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions