Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
switchProject(cwd, rootState) {
// If current .cwd
const currentCwd = rootState.project.cwd;
if (currentCwd) {
// Reset both session and project
dispatch.session.resetSession();
dispatch.project.resetProject();
}
// Change local .cwd
this.updateCwd(cwd);
// Add or update history's recent project
dispatch.history.addOrUpdateRecentProject(cwd);
},
},
const openedFiles = Array.from(state.project.openedFiles.values());
const currentFile = state.session.currentFile.filePath;
if (openedFiles.length <= 1) return;
let fileToOpen;
if (number === 9) {
// Opening the last file in the list
fileToOpen = openedFiles.slice(-1)[0];
} else if (openedFiles[number - 1]) {
// Number goes from 1~8, array from 0~7
fileToOpen = openedFiles[number - 1];
}
if (!fileToOpen || currentFile === fileToOpen) return;
dispatch.session.openFileAsync(fileToOpen.filePath);
}
.then(() => {
// Let our store know that there is no more unsaved changed
dispatch.session.savedFile();
resolve();
})
.catch(error => reject(error));
newFilePath => {
const fullNewFilePath = path.join(state.project.cwd, newFilePath);
console.log(fullNewFilePath);
dispatch.session.createFileAsync(fullNewFilePath);
}
);
if (nextIndex > openedFilesLength) {
nextFile = openedFiles[0];
} else {
nextFile = openedFiles[currentFileIndex + 1];
}
if (nextFile) {
fileToFallbackTo = nextFile.filePath;
}
break;
}
if (fileToFallbackTo) {
dispatch.session.openFileAsync(fileToFallbackTo);
}
}
onClick={() => dispatch.session.openFileAsync(file.filePath)}
>
dialog.showMessageBox(options, async response => {
if (response === 1) {
await dispatch.session.closeFileAsync(filePath);
if (!shell.moveItemToTrash(filePath)) {
log.info("Couldn't send", filePath, 'to trash');
}
}
});
},
select: () => {
const fullFilePath = path.join(state.project.cwd, filePath);
dispatch.session.openFileAsync(fullFilePath);
},
priority,
static format = async () => {
try {
const generatedCode = await FormatterManager.formatter.format();
dispatch.session.updateGeneratedCode({ generatedCode });
} catch (error) {
log.warn('[Error] Formatter: Could not parse code.');
}
};
newFilePath => {
dispatch.session.createFileAsync(newFilePath);
}
);