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

Commit undo checkpoints before each :write #11062

Merged
merged 1 commit into from
Jul 13, 2024
Merged

Commits on Jun 30, 2024

  1. Commit an undo checkpoint before each write

    This fixes the modification indicator when saving from insert mode with
    a config such as
    
        [keys.insert]
        C-s = ":write"
    
    Previously the modification indicator would be stuck showing modified
    even if the buffer contents matched the disk contents when writing after
    some changes in insert mode with this binding. In insert mode we do not
    eagerly write undo checkpoints so that all changes made become one
    checkpoint as you exit insert mode. When saving, `Document`s `changes`
    `ChangeSet` would be non-empty and when there are changes we show the
    buffer as modified. Then switching to normal mode would append the
    changes to history, bumping the current revision past what it was when
    last saved. Since the last saved revision and current revision were then
    unsynced, the modification indicator would always show modified.
    
    This matches [Kakoune's behavior]. Kakoune has a different architecture
    for writes but a very similar system for history, transactions and undo
    checkpoints (what it calls "undo groups"). Upon saving Kakoune creates
    an undo checkpoint if there are any uncommitted changes. It does this
    after the write has gone through since its writing system is different.
    For our writing system it's cleaner to make the undo checkpoint before
    performing the save so that the history revision increments before we
    send the save event.
    
    [Kakoune's behavior]: https://github.com/mawww/kakoune/blob/80fcfebca8c62ace6cf2af9487784486af07d2d5/src/buffer.cc#L565-L566
    the-mikedavis committed Jun 30, 2024
    Configuration menu
    Copy the full SHA
    f0f0f31 View commit details
    Browse the repository at this point in the history