本文整理汇总了TypeScript中vscode.workspace.updateWorkspaceFolders方法的典型用法代码示例。如果您正苦于以下问题:TypeScript workspace.updateWorkspaceFolders方法的具体用法?TypeScript workspace.updateWorkspaceFolders怎么用?TypeScript workspace.updateWorkspaceFolders使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vscode.workspace
的用法示例。
在下文中一共展示了workspace.updateWorkspaceFolders方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: isDirectory
isDirectory(newPath).then(isDir => {
if (isDir) {
if (selectedLabel === ".") {
const action = vscode.workspace.getConfiguration( "vscode-quick-browser" ).get( 'openCurrentFolderAction' );
if( action === "open in same window" ) {
vscode.commands.executeCommand( 'vscode.openFolder', new vscode.Uri( { scheme: 'file', path: qp.placeholder } ), false );
}
else if( action === "open in new window" ) {
vscode.commands.executeCommand( 'vscode.openFolder', new vscode.Uri( { scheme: 'file', path: qp.placeholder } ), true );
}
else if( action === "open new folder in same window" ) {
const { workspaceFolders } = vscode.workspace
vscode.workspace.updateWorkspaceFolders(
workspaceFolders ? workspaceFolders.length : 0,
null,
{
uri: vscode.Uri.file(newPath),
name: path.basename(newPath)
}
)
}
}
else {
updateQuickPick(qp, newPath)
}
}
else {
const openPath = vscode.Uri.file(newPath)
qp.hide()
vscode.workspace.openTextDocument(openPath).then(doc => {
return vscode.window.showTextDocument(doc)
})
}
}).catch(err => {
示例2: activate
export async function activate (context: ExtensionContext): Promise<void> {
// Misc.
Utils.ExtensionPath = context.extensionPath;
// Connect sockets
Sockets.Connect();
// Workspace
// context.subscriptions.push(workspace.registerFileSystemProvider('babylonjs-editor', new CustomFileSystem(), { isCaseSensitive: true, isReadonly: false }));
// workspace.updateWorkspaceFolders(0, 0, { uri: Uri.parse('babylonjs-editor:/'), name: "BabylonJSEditor" });
// Workspace
const fs = new TempFileSystem();
await fs.init();
workspace.updateWorkspaceFolders(0, 0, { uri: Uri.parse('file:/' + Utils.TempFolder), name: 'BabylonJSEditor' });
// Plugin
context.subscriptions.push(window.createTreeView('babylonjsEditorPlugin', { treeDataProvider: new BabylonJSEditorPlugin() }));
// Dispose
context.subscriptions.push({
dispose: async () => {
Watcher.Dispose();
await fs.clear();
}
});
}
示例3: createProject
async function createProject(projectPath: string, truffleBoxName: string): Promise<void> {
await fs.ensureDir(projectPath);
const arrayFiles = await fs.readdir(projectPath);
const path = (arrayFiles.length) ? createTemporaryDir(projectPath) : projectPath;
try {
window.showInformationMessage(Constants.informationMessage.newProjectCreationStarted);
Output.show();
await outputCommandHelper.executeCommand(path, 'npx', 'truffle', 'unbox', truffleBoxName);
if (arrayFiles.length) {
fs.moveSync(path, projectPath);
}
workspace.updateWorkspaceFolders(
0,
workspace.workspaceFolders ? workspace.workspaceFolders.length : null,
{uri: Uri.file(projectPath)});
window.showInformationMessage(Constants.informationMessage.newProjectCreationFinished);
} catch (error) {
// TODO: cleanup files after failed truffle unbox
throw Error(error);
}
}
示例4: connectAdtServer
export async function connectAdtServer(selector: any) {
const connectionID = selector && selector.connection
const remote = await selectRemote(connectionID)
if (!remote) return
const client = createClient(remote)
log(`Connecting to server ${remote.name}`)
try {
await client.login() // if connection raises an exception don't mount any folder
workspace.updateWorkspaceFolders(0, 0, {
uri: Uri.parse("adt://" + remote.name),
name: remote.name + "(ABAP)"
})
log(`Connected to server ${remote.name}`)
} catch (e) {
window.showErrorMessage(
`Failed to connect to ${remote.name}:${e.toString()}`
)
}
}
示例5:
).then((value: String | undefined) => {
if (value === 'Yes') {
vscode.workspace.updateWorkspaceFolders(0, null, { uri: vscode.Uri.file(workspaceRoot) })
}
})
示例6:
context.subscriptions.push(vscode.commands.registerCommand('memfs.workspaceInit', _ => {
vscode.workspace.updateWorkspaceFolders(0, 0, { uri: vscode.Uri.parse('memfs:/'), name: "MemFS - Sample" });
}));
示例7: setWorkspaceAndReload
/**
* Find and set a workspace root if no folders are open in the workspace. If there are already
* folders open in the workspace, do nothing.
*
* Adding a first folder to the workspace completely reloads the extension.
*/
function setWorkspaceAndReload(document: vscode.TextDocument) {
const documentPath = path.parse(document.uri.fsPath).dir
const workspaceRoot = findWorkspaceRoot(documentPath) || documentPath
vscode.workspace.updateWorkspaceFolders(0, null, { uri: vscode.Uri.file(workspaceRoot) })
}