Skip to content
This repository has been archived by the owner on May 28, 2020. It is now read-only.

Commit

Permalink
Revert "implement auto format on save (#13)" (#19)
Browse files Browse the repository at this point in the history
This reverts commit 6927e6a.
  • Loading branch information
justjavac authored Apr 11, 2019
1 parent 6927e6a commit 8d29205
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 33 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ You can configure the Deno extension using a `tsconfig` as described [here](http

- `deno.alwaysShowStatus` - Always show the Deno status bar item. Default is `true`.

- `deno.autoFmtOnSave` - Turns auto format on save on or off. Default is `false`.
- `deno.autoFmtOnSave` - Turns auto format on save on or off. Default is `false`. (**Not implemented**)

## Commands

Expand Down
32 changes: 0 additions & 32 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import {
isJavaScriptDocument,
getVersions
} from "./utils";
import * as execa from "execa";
import * as path from "path";

const typeScriptExtensionId = "vscode.typescript-language-features";
const pluginId = "typescript-deno-plugin";
Expand Down Expand Up @@ -183,40 +181,10 @@ export async function activate(context: ExtensionContext) {
context.subscriptions
);

const TextDocumentListener = workspace.onDidSaveTextDocument(
async document => {
const workspaceDenoConfig = workspace.getConfiguration(
configurationSection
);
const denoEnable = workspaceDenoConfig.get("enable", true);
const autoFmtOnSave = workspaceDenoConfig.get("autoFmtOnSave", false);

// if not enable the deno or not enable ``auto format on save``
if (!denoEnable || !autoFmtOnSave) {
return;
}

// TODO: ignore the large file. it will slowdown the extension
if (isTypeScriptDocument(document) || isJavaScriptDocument(document)) {
try {
// !!!: deno only support relative file path in currently
const filename = path.basename(document.uri.fsPath);
const cwd = path.dirname(document.uri.fsPath);
await execa("deno", [filename, "--fmt"], {
cwd
});
} catch {
// NOBUG: ignore error
}
}
}
);

synchronizeConfiguration(api);

const disposables = [
configurationListener,
TextDocumentListener,
commands.registerCommand("deno.enable", enable),
commands.registerCommand("deno.disable", disable),
commands.registerCommand("deno.showOutputChannel", async () => {
Expand Down

0 comments on commit 8d29205

Please sign in to comment.