Skip to content

Commit 79253d4

Browse files
author
Benjamin Pasero
committed
working copies - some JSDoc for clarification
1 parent 081fc61 commit 79253d4

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

src/vs/workbench/services/workingCopy/common/workingCopyService.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,21 @@ export const enum WorkingCopyCapabilities {
2222
Untitled = 1 << 1
2323
}
2424

25+
/**
26+
* Data to be associated with working copy backups. Use
27+
* `IBackupFileService.resolve(workingCopy.resource)` to
28+
* retrieve the backup when loading the working copy.
29+
*/
2530
export interface IWorkingCopyBackup {
31+
32+
/**
33+
* Any serializable metadata to be associated with the backup.
34+
*/
2635
meta?: object;
36+
37+
/**
38+
* Use this for larger textual content of the backup.
39+
*/
2740
content?: ITextSnapshot;
2841
}
2942

@@ -36,8 +49,17 @@ export interface IWorkingCopy {
3649

3750
//#region Events
3851

52+
/**
53+
* Used by the workbench to signal if the working copy
54+
* is dirty or not. Typically a working copy is dirty
55+
* once changed until saved or reverted.
56+
*/
3957
readonly onDidChangeDirty: Event<void>;
4058

59+
/**
60+
* Used by the workbench e.g. to trigger auto-save
61+
* (unless this working copy is untitled) and backups.
62+
*/
4163
readonly onDidChangeContent: Event<void>;
4264

4365
//#endregion
@@ -52,6 +74,14 @@ export interface IWorkingCopy {
5274

5375
//#region Save / Backup
5476

77+
/**
78+
* The workbench may call this method often after it receives
79+
* the `onDidChangeContent` event for the working copy. The motivation
80+
* is to allow to quit VSCode with dirty working copies present.
81+
*
82+
* Providers of working copies should use `IBackupFileService.resolve(workingCopy.resource)`
83+
* to retrieve the backup metadata associated when loading the working copy.
84+
*/
5585
backup(): Promise<IWorkingCopyBackup>;
5686

5787
save(options?: ISaveOptions): Promise<boolean>;

0 commit comments

Comments
 (0)