Skip to content

Commit

Permalink
Save before formatting happens
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaprieto committed Jan 30, 2023
1 parent 66a0737 commit 8dfbbf7
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 21 deletions.
21 changes: 11 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "juvix-mode",
"version": "0.1.22",
"version": "0.1.23",
"license": "GPL-3.0",
"description": "Juvix Mode for VSCode",
"displayName": "Juvix",
Expand Down Expand Up @@ -51,8 +51,8 @@
"@typescript-eslint/eslint-plugin": "^5.49.0",
"@typescript-eslint/parser": "^5.49.0",
"@vscode/test-electron": "^2.2.2",
"@vscode/vsce": "^2.16.0",
"eslint": "^8.32.0",
"@vscode/vsce": "^2.17.0",
"eslint": "^8.33.0",
"eslint-plugin-header": "^3.1.1",
"glob": "^8.1.0",
"mocha": "^10.2.0",
Expand Down Expand Up @@ -2419,7 +2419,7 @@
}
},
"dependencies": {
"@vscode/vsce": "^2.16.0",
"@vscode/vsce": "^2.17.0",
"mobx": "6.7.0",
"npx": "^10.2.2",
"run": "^1.4.0",
Expand Down
8 changes: 4 additions & 4 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ import * as formatter from './formatter';

export async function activate(context: vscode.ExtensionContext) {
debugChannel.clear();
repl.activate(context);
statusBar.activate(context);
inputMethod.activate(context);
tasks.activate(context);
syntaxHighlighter.activate(context);
goToDefinition.activate(context);
dev.activate(context);
tasks.activate(context);
inputMethod.activate(context);
repl.activate(context);
judoc.activate(context);
check.activate(context);
formatter.activate(context);
dev.activate(context);
debugChannel.info('Juvix extension is ready!');
}
12 changes: 9 additions & 3 deletions src/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,15 @@ export function activate(_context: vscode.ExtensionContext) {
filePath,
'--with-comments',
].join(' ');

const styledText = proc.execSync(formatterCall).toString();
return [vscode.TextEdit.replace(range, styledText)];
try {
document.save();
debugChannel.appendLine('Saved file before formatting');
const styledText = proc.execSync(formatterCall).toString();
return [vscode.TextEdit.replace(range, styledText)];
} catch (error) {
debugChannel.info('Error formatting file', error);
}
return [];
},
});
}

0 comments on commit 8dfbbf7

Please sign in to comment.