forked from microsoft/vscode-pull-request-github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathissueFile.ts
More file actions
56 lines (53 loc) · 2.37 KB
/
Copy pathissueFile.ts
File metadata and controls
56 lines (53 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
export class IssueFileSystemProvider implements vscode.FileSystemProvider {
private content: Uint8Array | undefined;
private createTime: number = 0;
private modifiedTime: number = 0;
private _onDidChangeFile: vscode.EventEmitter<vscode.FileChangeEvent[]> = new vscode.EventEmitter<vscode.FileChangeEvent[]>();
onDidChangeFile: vscode.Event<vscode.FileChangeEvent[]> = this._onDidChangeFile.event;
watch(_uri: vscode.Uri, _options: { recursive: boolean; excludes: string[]; }): vscode.Disposable {
const disposable = this.onDidChangeFile(e => {
if (e.length === 0 && e[0].type === vscode.FileChangeType.Deleted) {
disposable.dispose();
}
})
return disposable;
}
stat(_uri: vscode.Uri): vscode.FileStat {
return {
type: vscode.FileType.File,
ctime: this.createTime,
mtime: this.modifiedTime,
size: this.content?.length ?? 0
};
}
readDirectory(_uri: vscode.Uri): [string, vscode.FileType][] | Thenable<[string, vscode.FileType][]> {
return [];
}
createDirectory(_uri: vscode.Uri): void { }
readFile(_uri: vscode.Uri): Uint8Array | Thenable<Uint8Array> {
return this.content ?? new Uint8Array(0);
}
writeFile(uri: vscode.Uri, content: Uint8Array, _options: { create: boolean; overwrite: boolean; } = { create: false, overwrite: false }): void | Thenable<void> {
const oldContent = this.content;
this.content = content;
if (oldContent === undefined) {
this.createTime = new Date().getTime();
this._onDidChangeFile.fire([{ uri: uri, type: vscode.FileChangeType.Created }]);
} else {
this.modifiedTime = new Date().getTime();
this._onDidChangeFile.fire([{ uri: uri, type: vscode.FileChangeType.Changed }]);
}
}
delete(uri: vscode.Uri, _options: { recursive: boolean; }): void | Thenable<void> {
this.content = undefined;
this.createTime = 0;
this.modifiedTime = 0;
this._onDidChangeFile.fire([{ uri: uri, type: vscode.FileChangeType.Deleted }]);
}
rename(_oldUri: vscode.Uri, _newUri: vscode.Uri, _options: { overwrite: boolean; }): void | Thenable<void> { }
}