Skip to content

Commit

Permalink
rename file fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ankushKun committed Jun 17, 2024
1 parent 4b705c8 commit 61e12d3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
6 changes: 3 additions & 3 deletions next_app/src/components/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -547,11 +547,11 @@ $$\\int_a^b f'(x) dx = f(b)- f(a)$$`,
runNormalCode();
});
}}
value={file ? file.content.cells[0].code : ""}
value={file ? file.content.cells[file.content.cellOrder[0]].code : ""}
onChange={(value) => {
const newContent = { ...file.content };
newContent.cells[0] = {
...file.content.cells[0],
newContent.cells[file.content.cellOrder[0]] = {
...file.content.cells[file.content.cellOrder[0]],
code: value,
};
manager.updateFile(project, { file, content: newContent });
Expand Down
17 changes: 15 additions & 2 deletions next_app/src/components/side-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,22 @@ export default function SideBar({ collapsed, setCollapsed, manager }: { collapse
Duplicate file
</Button>
<Button
disabled
onClick={() => {
// manager.renameFile(manager.getProject(pname), fname);
const newName = prompt("Enter the new name for the file");
if (!newName) return;
const p = manager.getProject(pname);
const oldFile = p.files[fname];
manager.newFile(p, { name: newName, type: oldFile.type, initialContent: '' });
const newFile = p.getFile(newName);
newFile.content = oldFile.content;
manager.deleteFile(p, fname);
globalState.closeFile(fname);
globalState.fileDeleted(fname);
globalState.setActiveFile(newName);
p.files[newName] = newFile;
manager.projects[pname] = p;
manager.saveProjects(manager.projects);

}}
>
Rename file
Expand Down

0 comments on commit 61e12d3

Please sign in to comment.