CodingTrain / Bizarro-Devin

12 stars 4 forks source link

Arrange windows vertically #9

Closed supercrafter100 closed 5 months ago

supercrafter100 commented 5 months ago

This PR it's base branch is my previous one #8 hence the many changes. The actual notable ones are in the extension.js file line 43 to line 62. If it's an issue I'll adapt this PR to have the current main branch as the base branch and only reflect those changes. I'm just afraid my other pr will massively conflict then 😅

https://github.com/CodingTrain/Bizarro-Devin/assets/58982133/5baf97a5-bdc8-4d9e-b7a5-d06287ed3ae9

This PR should close #2

shiffman commented 5 months ago

I might change how this all works, but it's great to see how the code works and have this in there for now, thank you!

JuggernautJf commented 5 months ago

@dipamsen How i create file in workspace: createFile.js

import vscode from 'vscode';

/**
 * Creates a file with the given relative path and optional content.
*
* @param {string} path - The relative path of the file to be created.
* @param {string} [content] - The content to be written to the file. Optional, defaults to an empty string.
* @return {Promise<void>} - A promise that resolves when the file is created successfully.
* @param {boolean} options.show - set true to open file
*/
export async function createFile (path, content = "",options={}) => {
  const activeFolder = vscode.workspace.workspaceFolders?.[0];
  const FilePath = vscode.Uri.joinPath(activeFolder.uri, path);
  const FileContent = new TextEncoder().encode(content);
  await vscode.workspace.fs.writeFile(FilePath, FileContent);
  if (options.show) {
    const document = await vscode.workspace.openTextDocument(FilePath);
    await vscode.window.showTextDocument(document);
  }
};

extension.js

import { createFile } from 'utils/createFile.js'

const createIndexHtml = async() => await createFile('index.html', 
`<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>

</body>
</html>`);

const createSketchJs = async() => await createFile('sketch.js',"",{show : true});