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 Autosave for open buffers #3637

Merged
merged 7 commits into from
Aug 11, 2022
Merged

Conversation

hubertp
Copy link
Contributor

@hubertp hubertp commented Aug 9, 2022

Pull Request Description

This change adds Autosave action for open buffers. The action is scheduled
after every edit request and is cancelled by every explicit save file request, if
necessary. Successful autosave also notifies any active clients of the buffer.

Related to https://www.pivotaltracker.com/story/show/182721656

Important Notes

WIP

Checklist

Please include the following checklist in your PR:

  • The documentation has been updated if necessary.
  • All code conforms to the
    Scala,
    Java,
    and
    Rust
    style guides.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed: Enso GUI was tested when built using BOTH
      ./run ide dist and ./run ide watch.

@hubertp hubertp changed the title Auto-save between edits Support Autosave for open buffers Aug 9, 2022
@hubertp hubertp force-pushed the wip/hubert/autosave-182721656 branch from 9bc75e4 to cba99e9 Compare August 9, 2022 14:06
@hubertp hubertp marked this pull request as ready for review August 9, 2022 14:06
### `text/autoSave`

This is a notification sent from the server to the clients to inform them of any
successful auto-save action.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

timeoutCancellable: Cancellable
): Receive = {
case IOTimeout =>
replyTo ! SaveFailed(OperationTimeout)
replyTo.foreach(_ ! SaveFailed(OperationTimeout))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replyTo be None and None.foreach is a check to do nothing, I see.

Copy link
Contributor

@4e6 4e6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized that there is a text/openBuffer command that creates an in-memory buffer. And we should not run the auto-save logic for buffers that were opened this way.

I think we can get away with an extra isInMemory state in the CollaborativeBuffer actor

This change adds the auto-save action that will be schedule after every
edit request. If no edit happens after the auto-save delay, language
server will automatically trigger file saving.

This does not yet trigger propagate the information about the successful
save to the sender of the last edit request.
Minor cleanup to avoid spurious messages.
@hubertp hubertp force-pushed the wip/hubert/autosave-182721656 branch from f797a8f to 0f67a00 Compare August 11, 2022 09:17
@hubertp hubertp requested a review from 4e6 August 11, 2022 09:17
Copy link
Contributor

@4e6 4e6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@hubertp hubertp added the CI: Ready to merge This PR is eligible for automatic merge label Aug 11, 2022
@mergify mergify bot merged commit 3fa78af into develop Aug 11, 2022
@mergify mergify bot deleted the wip/hubert/autosave-182721656 branch August 11, 2022 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants