Skip to content

Commit

Permalink
fix formatting for files where types are inserted
Browse files Browse the repository at this point in the history
  • Loading branch information
rikukissa committed May 22, 2021
1 parent c7a63c0 commit a7b34b5
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 14 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ configure({

## Release Notes

## [1.6.1] - 2021-05-22

### Fixed

- Fix the automatic formatting in files where types are inserted

## [1.6.0] - 2021-05-20

### Added
Expand Down
4 changes: 2 additions & 2 deletions packages/extension/package-lock.json

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

2 changes: 1 addition & 1 deletion packages/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"publisher": "rikurouvila",
"description": "🧪 Take samples of runtime values and turn them into type definitions automatically",
"repository": "https://github.com/rikukissa/typehole",
"version": "1.6.0",
"version": "1.6.1",
"private": true,
"icon": "images/logo.png",
"galleryBanner": {
Expand Down
19 changes: 11 additions & 8 deletions packages/extension/src/listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,7 @@ function createServer() {

fastify.post("/samples", async (request, reply) => {
const body = request.body as any;
log(
body.id,
"-",
"New sample",
JSON.stringify(request.body).substr(0, 30),
"received"
);
log(body.id, "-", "New sample", JSON.stringify(request.body), "received");

const samples = addSample(body.id, body.sample);
const typeString = samplesToType(samples);
Expand Down Expand Up @@ -200,7 +194,16 @@ async function updateTypes(hole: Typehole, types: string, fileName: string) {
vscode.workspace.applyEdit(workEdits);

try {
await vscode.commands.executeCommand("editor.action.formatDocument");
const workEdits = new vscode.WorkspaceEdit();
const edits = await vscode.commands.executeCommand<vscode.TextEdit[]>(
"vscode.executeFormatDocumentProvider",
document.uri
);

if (edits) {
workEdits.set(document.uri, edits);
vscode.workspace.applyEdit(workEdits);
}
} catch (err) {
error("Formatting the document failed", err.message);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/runtime/package-lock.json

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

2 changes: 1 addition & 1 deletion packages/runtime/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.6.0",
"version": "1.6.1",
"name": "typehole",
"repository": "rikukissa/typehole",
"description": "Turn runtime types into static typescript types automatically",
Expand Down

0 comments on commit a7b34b5

Please sign in to comment.