#3920: Notebooks file save/save all/cache - for existing files (#4286)

* #3920: Notebooks file save

* Missed in merge

* #4290: Untitled save and native dirty implementation

* Misc changes

* Content Manager, notebooks extension and commented failed unit tests

* Removing modelLoaded event
This commit is contained in:
Raj
2019-03-07 18:07:20 -08:00
committed by GitHub
parent 2a903e9f03
commit 036ffe595a
15 changed files with 486 additions and 400 deletions

View File

@@ -37,6 +37,33 @@ import { ICodeActionsOnSaveOptions } from 'vs/editor/common/config/editorOptions
import { IBulkEditService } from 'vs/editor/browser/services/bulkEditService';
import { CancellationTokenSource } from 'vs/base/common/cancellation';
// {{SQL CARBON EDIT}}
import { INotebookService } from 'sql/workbench/services/notebook/common/notebookService';
/*
* An update participant that ensures any un-tracked changes are synced to the JSON file contents for a
* Notebook before save occurs. While every effort is made to ensure model changes are notified and a listener
* updates the backing model in-place, this is a backup mechanism to hard-update the file before save in case
* some are missed.
*/
class NotebookUpdateParticipant implements ISaveParticipantParticipant {
constructor(
@INotebookService private notebookService: INotebookService
) {
// Nothing
}
public participate(model: ITextFileEditorModel, env: { reason: SaveReason }): void {
let uriString = model.getResource().toString();
let notebookEditor = this.notebookService.listNotebookEditors().find((editor) => editor.id === uriString);
if (notebookEditor) {
notebookEditor.notebookParams.input.updateModel();
}
}
}
export interface ISaveParticipantParticipant extends ISaveParticipant {
// progressMessage: string;
}
@@ -388,6 +415,8 @@ export class SaveParticipant implements ISaveParticipant {
instantiationService.createInstance(FormatOnSaveParticipant),
instantiationService.createInstance(FinalNewLineParticipant),
instantiationService.createInstance(TrimFinalNewLinesParticipant),
// {{SQL CARBON EDIT}}
instantiationService.createInstance(NotebookUpdateParticipant),
instantiationService.createInstance(ExtHostSaveParticipant, extHostContext),
]);
// Hook into model