This commit is contained in:
Timothy J. Baek
2024-06-10 17:52:12 -07:00
parent c2e6e44714
commit c5ed3452d2
2 changed files with 42 additions and 15 deletions

View File

@@ -26,7 +26,6 @@
export const formatPythonCodeHandler = async () => {
if (codeEditor) {
console.log('formatPythonCodeHandler');
const res = await formatPythonCode(value).catch((error) => {
toast.error(error);
return null;
@@ -111,11 +110,16 @@
// Add a keyboard shortcut to format the code when Ctrl/Cmd + S is pressed
// Override the default browser save functionality
const handleSave = (e) => {
const handleSave = async (e) => {
if ((e.ctrlKey || e.metaKey) && e.key === 's') {
e.preventDefault();
formatPythonCodeHandler();
dispatch('save');
const res = await formatPythonCodeHandler().catch((error) => {
return null;
});
if (res) {
dispatch('save');
}
}
};