Skip to content

Commit

Permalink
src/goCover: clear cached coverage info on save
Browse files Browse the repository at this point in the history
This is a fix for the regression in ms-vscode.Go@0.14.2

The `isDirty` bit of the TextDocument when vscode.workspace.onDidSaveTextDocument is
already false.  Adjust the condition for clearing cache not to check it.
Modification should be tracked already by trackCodeCoverageRemovalOnFileChange.

And let modifiedFiles start with an empty value rather than as undefined.

Fixes github.com/microsoft/issues/3252.
  • Loading branch information
hyangah committed May 19, 2020
1 parent af182cc commit fbfddd9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/goCover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ let decoratorConfig: {
// a list of modified, unsaved go files with actual code edits (rather than comment edits)
let modifiedFiles: {
[key: string]: boolean;
};
} = {};

/**
* Initializes the decorators used for Code coverage.
Expand Down Expand Up @@ -298,7 +298,7 @@ export function applyCodeCoverage(editor: vscode.TextEditor) {
* @param e TextDocument
*/
export function removeCodeCoverageOnFileSave(e: vscode.TextDocument) {
if (e.languageId !== 'go' || !isCoverageApplied || !e.isDirty) {
if (e.languageId !== 'go' || !isCoverageApplied) {
return;
}

Expand Down

0 comments on commit fbfddd9

Please sign in to comment.