本文整理汇总了TypeScript中vscode.window.showWorkspaceFolderPick方法的典型用法代码示例。如果您正苦于以下问题:TypeScript window.showWorkspaceFolderPick方法的具体用法?TypeScript window.showWorkspaceFolderPick怎么用?TypeScript window.showWorkspaceFolderPick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vscode.window
的用法示例。
在下文中一共展示了window.showWorkspaceFolderPick方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: selectWorkspaceFolder
private async selectWorkspaceFolder(): Promise<WorkspaceFolder | undefined> {
if (workspace.workspaceFolders.length === 1) {
return workspace.workspaceFolders[0];
}
const sourcePath = await this.getSourcePath();
const uri = Uri.file(sourcePath);
return workspace.getWorkspaceFolder(uri) || window.showWorkspaceFolderPick();
}
示例2: test
test('showWorkspaceFolderPick', async function () {
const p = window.showWorkspaceFolderPick(undefined);
await commands.executeCommand('workbench.action.acceptSelectedQuickOpenItem');
try {
await p;
assert.ok(true);
}
catch (_error) {
assert.ok(false);
}
});
示例3: async
vscode.commands.registerCommand('config.commands.configureEmptyLastLineFiles', async () => {
// 1) Getting the value
const value = await vscode.window.showInputBox({ prompt: 'Provide glob pattern of files to have empty last line.' });
if (vscode.workspace.workspaceFolders) {
// 2) Getting the target
const target = await vscode.window.showQuickPick(
[
{ label: 'Application', description: 'User Settings', target: vscode.ConfigurationTarget.Global },
{ label: 'Workspace', description: 'Workspace Settings', target: vscode.ConfigurationTarget.Workspace },
{ label: 'Workspace Folder', description: 'Workspace Folder Settings', target: vscode.ConfigurationTarget.WorkspaceFolder }
],
{ placeHolder: 'Select the target to which this setting should be applied' });
if (value && target) {
if (target.target === vscode.ConfigurationTarget.WorkspaceFolder) {
// 3) Getting the workspace folder
let workspaceFolder = await vscode.window.showWorkspaceFolderPick({ placeHolder: 'Pick Workspace Folder to which this setting should be applied' })
if (workspaceFolder) {
// 4) Get the configuration for the workspace folder
const configuration = vscode.workspace.getConfiguration('', workspaceFolder.uri);
// 5) Get the current value
const currentValue = configuration.get('conf.resource.insertEmptyLastLine');
const newValue = { ...currentValue, ...{ [value]: true } };
// 6) Update the configuration value
await configuration.update('conf.resource.insertEmptyLastLine', newValue, target.target);
}
} else {
// 3) Get the configuration
const configuration = vscode.workspace.getConfiguration();
// 4) Get the current value
const currentValue = configuration.get('conf.resource.insertEmptyLastLine');
const newValue = { ...currentValue, ...{ [value]: true } };
// 3) Update the value in the target
await vscode.workspace.getConfiguration().update('conf.resource.insertEmptyLastLine', newValue, target.target);
}
}
} else {
// 2) Get the configuration
const configuration = vscode.workspace.getConfiguration();
// 3) Get the current value
const currentValue = configuration.get('conf.resource.insertEmptyLastLine');
const newValue = { ...currentValue, ...{ [value]: true } };
// 4) Update the value in the User Settings
await vscode.workspace.getConfiguration().update('conf.resource.insertEmptyLastLine', newValue, vscode.ConfigurationTarget.Global);
}
});
示例4: activate
//.........这里部分代码省略.........
for (let d of availableDebuggers) {
if (d.getDisplayName() === result) {
let prefs = this.getPreferences(workspace);
if (prefs.getAutoSaveOnDeploy()) {
vscode.workspace.saveAll();
}
return await d.runDeployer(await prefs.getTeamNumber(), workspace);
}
}
await vscode.window.showInformationMessage('Debug exited');
return false;
}
return false;
},
registerCodeDebug(deployer: ICodeDeployer): void {
codeDebuggers.push(deployer);
},
getApiVersion(): number {
return 1;
},
getPreferences(workspace: vscode.WorkspaceFolder): IPreferences {
for (let p of preferences) {
if (p.workspace.uri === workspace.uri) {
return p;
}
}
return preferences[0];
},
addLanguageChoice(language: string): void {
languageChoices.push(language);
},
async requestLanguageChoice(): Promise<string> {
if (languageChoices.length <= 0) {
return '';
}
let result = await vscode.window.showQuickPick(languageChoices, { placeHolder: 'Pick a language' } );
if (result === undefined) {
return '';
}
return result;
},
async getFirstOrSelectedWorkspace(): Promise<vscode.WorkspaceFolder | undefined> {
let wp = vscode.workspace.workspaceFolders;
if (wp === undefined) {
return;
}
let workspace = wp[0];
if (wp.length > 1) {
let res = await vscode.window.showWorkspaceFolderPick();
if (res !== undefined) {
workspace = res;
}
}
return workspace;
}
};
// Use the console to output diagnostic information (console.log) and errors (console.error)
// This line of code will only be executed once when your extension is activated
console.log('Congratulations, your extension "vscode-wpilib-core" is now active!');
context.subscriptions.push(vscode.commands.registerCommand('wpilibcore.startRioLog', async () =>{
let workspace = await api.getFirstOrSelectedWorkspace();
if (workspace === undefined) {
return;
}
await api.startRioLog(await api.getPreferences(workspace).getTeamNumber());
}));
context.subscriptions.push(vscode.commands.registerCommand('wpilibcore.setTeamNumber', async () =>{
let workspace = await api.getFirstOrSelectedWorkspace();
if (workspace === undefined) {
return;
}
await api.getPreferences(workspace).setTeamNumber(await requestTeamNumber());
}));
context.subscriptions.push(vscode.commands.registerCommand('wpilibcore.startTool', async () =>{
await api.startTool();
}));
context.subscriptions.push(vscode.commands.registerCommand('wpilibcore.deployCode', async () =>{
let workspace = await api.getFirstOrSelectedWorkspace();
if (workspace === undefined) {
return;
}
await api.deployCode(workspace);
}));
context.subscriptions.push(vscode.commands.registerCommand('wpilibcore.debugCode', async () =>{
let workspace = await api.getFirstOrSelectedWorkspace();
if (workspace === undefined) {
return;
}
await api.debugCode(workspace);
}));
return api;
}