本文整理匯總了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) })
}