Skip to content

Commit 776ca03

Browse files
committed
Make linter tolerant to '--showfile' option
This forces '--showfile' mode to make linter stable whether the option passed directly by the arg or implicitly by .config file
1 parent 60ce39c commit 776ca03

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/checkpatchProvider.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ export default class CheckpatchProvider implements vscode.CodeActionProvider {
102102

103103
private parseCheckpatchLog(log: string, basePath: string): number {
104104
const dictionary: { [fileUri: string]: vscode.Diagnostic[] } = {};
105-
var re = /(WARNING|ERROR|CHECK): ?(.+):(.+)?(?:\n|\r\n|)#\d+: FILE: (.*):(\d+):/g;
105+
var re = /(.*):(\d+): (WARNING|ERROR|CHECK): ?(.+):(.+)/g;
106106
var matches;
107107

108108
while (matches = re.exec(log)) {
109-
let type = matches[2];
110-
let message = matches[3];
111-
let fileName = matches[4];
112-
let errorline = parseInt(matches[5]);
109+
let fileName = matches[1];
110+
let errorline = parseInt(matches[2]);
111+
let type = matches[4];
112+
let message = matches[5];
113113
let range = new vscode.Range(errorline - 1, 0, errorline - 1, Number.MAX_VALUE);
114114
let diagnostic = new vscode.Diagnostic(range, `${type}:${message}`, this.linterConfig.diagnosticSeverity);
115115

@@ -143,7 +143,9 @@ export default class CheckpatchProvider implements vscode.CodeActionProvider {
143143
let log = '';
144144
let args = this.linterConfig.args.slice();
145145
let cwd = vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders[0].uri.fsPath : undefined;
146-
args.push('--show-types -f');
146+
args.push('--show-types');
147+
args.push('--showfile');
148+
args.push('-f');
147149
args.push(textDocument.fileName.replace(/\\/g, '/'));
148150

149151
let childProcess = cp.spawn(this.linterConfig.path, args, { shell: true, cwd: cwd });
@@ -195,6 +197,7 @@ export default class CheckpatchProvider implements vscode.CodeActionProvider {
195197
if (commitValue && commitValue.description) {
196198
let log = '';
197199
let args = this.linterConfig.args.slice();
200+
args.push('--showfile');
198201
args.push('-g');
199202
args.push(commitValue.description);
200203

0 commit comments

Comments
 (0)