Skip to content

Commit

Permalink
Fix CUE Diagnostics (#11)
Browse files Browse the repository at this point in the history
Fix CUE Diagnostics by using `cue vet` to return any "problems" if they exist.

Co-authored-by: Jasmine Hundal <[email protected]>
  • Loading branch information
jasmineHundal and Jasmine Hundal authored Nov 3, 2022
1 parent c192967 commit 4b5decc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how

## [Unreleased]

- [11](https://github.com/johnallen3d/vscode-cue-fmt/pull/11): Fix CUE Diagnostics - [@jasmineHundal](https://github.com/jasmineHundal)

## [0.1.1] - 2021-12-22

- [5](https://github.com/johnallen3d/vscode-cue-fmt/pull/5): Setup GitHub actions for linting and release workflows - [@johnallen3d](https://github.com/johnallen3d)
Expand Down
9 changes: 6 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@ function provideDocumentFormattingEdits(document: TextDocument): TextEdit[] {
// copy current contents to a temporary file
writeFileSync(tmpfile, document.getText());

// run `cue fmt` on temp file
const fmt = spawnSync("cue", ["fmt", tmpfile], {});
// run `cue vet` to return errors
const vet = spawnSync("cue", ["vet", tmpfile], {});

// refresh diagnostics/problems
updateDiagnostics(document, fmt.stderr.toString(), tmpfilePrefix);
updateDiagnostics(document, vet.stderr.toString(), tmpfilePrefix);

// run `cue fmt` on temp file
spawnSync("cue", ["fmt", tmpfile], {});

// read formatted file
const formatted = readFileSync(tmpfile).toString();
Expand Down

0 comments on commit 4b5decc

Please sign in to comment.