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

Commit af27a9c

Browse files
Merge pull request #110 from clang13/readability-problem-location
Add a setting for where readability problems are displayed
2 parents 4ea2beb + 9420c13 commit af27a9c

File tree

5 files changed

+53
-17
lines changed

5 files changed

+53
-17
lines changed

package-lock.json

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,21 @@
6868
"type": "boolean",
6969
"default": false,
7070
"description": "Do not show warning dialog that a file must be saved to be linted."
71+
},
72+
"vale.readabilityProblemLocation": {
73+
"type": "string",
74+
"enum": [
75+
"status",
76+
"inline",
77+
"both"
78+
],
79+
"default": "status",
80+
"markdownEnumDescriptions": [
81+
"Displays readability problems in the status bar.",
82+
"Displays readability problems inline with other problems.",
83+
"Displays readability problems both in the status bar and inline in the file."
84+
],
85+
"markdownDescription": "Determines where file-level readability problems are displayed."
7186
}
7287
}
7388
}

src/features/vsProvider.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as fs from "fs";
55
import * as vscode from "vscode";
66

77
import * as utils from "./vsUtils";
8+
import { getReadabilityProblemLocation } from "./vsUtils";
89

910
export default class ValeProvider implements vscode.CodeActionProvider {
1011
private diagnosticCollection!: vscode.DiagnosticCollection;
@@ -103,14 +104,20 @@ export default class ValeProvider implements vscode.CodeActionProvider {
103104
return;
104105
}
105106

107+
const readabilityProblemLocation = getReadabilityProblemLocation()
106108
this.readabilityStatus.hide();
109+
107110
for (let key in body) {
108111
const alerts = body[key];
109112
for (var i = 0; i < alerts.length; ++i) {
110-
if (alerts[i].Match === "") {
113+
const isReadabilityProblem = alerts[i].Match === ""
114+
115+
if (isReadabilityProblem && readabilityProblemLocation !== "inline") {
111116
var readabilityMessage = alerts[0].Message;
112117
this.updateStatusBarItem(readabilityMessage);
113-
} else {
118+
}
119+
120+
if (!isReadabilityProblem || readabilityProblemLocation !== "status") {
114121
let diagnostic = utils.toDiagnostic(
115122
alerts[i],
116123
this.stylesPath,

src/features/vsTypes.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,8 @@ interface IValeErrorJSON {
3030
readonly Span: [number, number];
3131
readonly Severity: ValeSeverity;
3232
}
33+
34+
/**
35+
* Where to display file-level readability problems.
36+
*/
37+
type ValeReadabilityProblemLocation = "both" | "inline" | "status";

src/features/vsUtils.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,3 +266,12 @@ export const buildCommand = (
266266
command = command.concat(["--output", "JSON", path]);
267267
return command;
268268
};
269+
270+
export const getReadabilityProblemLocation = (): ValeReadabilityProblemLocation => {
271+
const configuration = vscode.workspace.getConfiguration();
272+
273+
return configuration.get<ValeReadabilityProblemLocation>(
274+
"vale.readabilityProblemLocation",
275+
"status"
276+
);
277+
}

0 commit comments

Comments
 (0)