This pull request introduces a new SaveActiveBuffer command that is dispatched when either pressing ⌘S or CtrlS. This new command applies to both local and remote workspaces, which in the latter case issues a save request to the host owning the buffer.
The save routine is carried out on a separate thread thanks to the introduction of Buffer::snapshot, which builds a read-only Sendable clone of the current state of the buffer. Then, after successfully grabbing the file's lock in a background thread, the buffer's tree of visible fragments is traversed, encoded to UTF-8, and written to disk in a streaming fashion.
At some point in the future we should handle different encodings, as well as coping with file corruption in the presence of an error in a graceful way.
This pull request introduces a new
SaveActiveBuffer
command that is dispatched when either pressing ⌘S or CtrlS. This new command applies to both local and remote workspaces, which in the latter case issues a save request to the host owning the buffer.The save routine is carried out on a separate thread thanks to the introduction of
Buffer::snapshot
, which builds a read-onlySend
able clone of the current state of the buffer. Then, after successfully grabbing the file's lock in a background thread, the buffer's tree of visible fragments is traversed, encoded to UTF-8, and written to disk in a streaming fashion.At some point in the future we should handle different encodings, as well as coping with file corruption in the presence of an error in a graceful way.