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

Commit

Permalink
Merge pull request #110 from clang13/readability-problem-location
Browse files Browse the repository at this point in the history
Add a setting for where readability problems are displayed
  • Loading branch information
ChrisChinchilla authored Oct 20, 2022
2 parents 4ea2beb + 9420c13 commit af27a9c
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 17 deletions.
30 changes: 15 additions & 15 deletions package-lock.json

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

15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@
"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
5 changes: 5 additions & 0 deletions src/features/vsTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@ interface IValeErrorJSON {
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 @@ -266,3 +266,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 af27a9c

Please sign in to comment.