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 => {
Esempio n. 2
0
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();
        }
    });
}
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);
  }
}
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()}`
    )
  }
}
Esempio n. 5
0
 ).then((value: String | undefined) => {
   if (value === 'Yes') {
     vscode.workspace.updateWorkspaceFolders(0, null, { uri: vscode.Uri.file(workspaceRoot) })
   }
 })
 context.subscriptions.push(vscode.commands.registerCommand('memfs.workspaceInit', _ => {
     vscode.workspace.updateWorkspaceFolders(0, 0, { uri: vscode.Uri.parse('memfs:/'), name: "MemFS - Sample" });
 }));
Esempio n. 7
0
/**
 * 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) })
}