Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Commit

Permalink
Add a setting for where readability problems are displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
clang13 committed Oct 4, 2022
1 parent 677fb65 commit 7e4d43e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,23 @@
"type": "boolean",
"default": false,
"description": "Do not show warning dialog that a file must be saved to be linted."
},
"vale.readabilityProblemLocation": {
"type": "string",
"enum": [
"status",
"inline",
"both"
],
"default": "status",
"markdownEnumDescriptions": [
"Displays readability problems in the status bar.",
"Displays readability problems inline with other problems.",
"Displays readability problems both in the status bar and inline in the file."
],
"markdownDescription": "Determines where file-level readability problems are displayed."
}

}
}
},
Expand Down
11 changes: 9 additions & 2 deletions src/features/vsProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as fs from "fs";
import * as vscode from "vscode";

import * as utils from "./vsUtils";
import { getReadabilityProblemLocation } from "./vsUtils";

export default class ValeProvider implements vscode.CodeActionProvider {
private diagnosticCollection!: vscode.DiagnosticCollection;
Expand Down Expand Up @@ -103,14 +104,20 @@ export default class ValeProvider implements vscode.CodeActionProvider {
return;
}

const readabilityProblemLocation = getReadabilityProblemLocation()
this.readabilityStatus.hide();

for (let key in body) {
const alerts = body[key];
for (var i = 0; i < alerts.length; ++i) {
if (alerts[i].Match === "") {
const isReadabilityProblem = alerts[i].Match === ""

if (isReadabilityProblem && readabilityProblemLocation !== "inline") {
var readabilityMessage = alerts[0].Message;
this.updateStatusBarItem(readabilityMessage);
} else {
}

if (!isReadabilityProblem || readabilityProblemLocation !== "status") {
let diagnostic = utils.toDiagnostic(
alerts[i],
this.stylesPath,
Expand Down
7 changes: 6 additions & 1 deletion src/features/vsTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ interface IValeErrorJSON {
readonly Message: string;
readonly Span: [number, number];
readonly Severity: ValeSeverity;
}
}

/**
* Where to display file-level readability problems.
*/
type ValeReadabilityProblemLocation = "both" | "inline" | "status";
9 changes: 9 additions & 0 deletions src/features/vsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,12 @@ export const buildCommand = (
command = command.concat(["--output", "JSON", path]);
return command;
};

export const getReadabilityProblemLocation = (): ValeReadabilityProblemLocation => {
const configuration = vscode.workspace.getConfiguration();

return configuration.get<ValeReadabilityProblemLocation>(
"vale.readabilityProblemLocation",
"status"
);
}

0 comments on commit 7e4d43e

Please sign in to comment.