forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkspaceApis.ts
More file actions
61 lines (48 loc) · 2.14 KB
/
workspaceApis.ts
File metadata and controls
61 lines (48 loc) · 2.14 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
57
58
59
60
61
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import * as vscode from 'vscode';
import { Resource } from '../types';
export function getWorkspaceFolders(): readonly vscode.WorkspaceFolder[] | undefined {
return vscode.workspace.workspaceFolders;
}
export function getWorkspaceFolder(uri: Resource): vscode.WorkspaceFolder | undefined {
return uri ? vscode.workspace.getWorkspaceFolder(uri) : undefined;
}
export function getWorkspaceFolderPaths(): string[] {
return vscode.workspace.workspaceFolders?.map((w) => w.uri.fsPath) ?? [];
}
export function getConfiguration(
section?: string,
scope?: vscode.ConfigurationScope | null,
): vscode.WorkspaceConfiguration {
return vscode.workspace.getConfiguration(section, scope);
}
export function applyEdit(edit: vscode.WorkspaceEdit): Thenable<boolean> {
return vscode.workspace.applyEdit(edit);
}
export function findFiles(
include: vscode.GlobPattern,
exclude?: vscode.GlobPattern | null,
maxResults?: number,
token?: vscode.CancellationToken,
): Thenable<vscode.Uri[]> {
return vscode.workspace.findFiles(include, exclude, maxResults, token);
}
export function onDidCloseTextDocument(handler: (e: vscode.TextDocument) => unknown): vscode.Disposable {
return vscode.workspace.onDidCloseTextDocument(handler);
}
export function onDidSaveTextDocument(handler: (e: vscode.TextDocument) => unknown): vscode.Disposable {
return vscode.workspace.onDidSaveTextDocument(handler);
}
export function getOpenTextDocuments(): readonly vscode.TextDocument[] {
return vscode.workspace.textDocuments;
}
export function onDidOpenTextDocument(handler: (doc: vscode.TextDocument) => unknown): vscode.Disposable {
return vscode.workspace.onDidOpenTextDocument(handler);
}
export function onDidChangeTextDocument(handler: (e: vscode.TextDocumentChangeEvent) => unknown): vscode.Disposable {
return vscode.workspace.onDidChangeTextDocument(handler);
}
export function onDidChangeConfiguration(handler: (e: vscode.ConfigurationChangeEvent) => unknown): vscode.Disposable {
return vscode.workspace.onDidChangeConfiguration(handler);
}