Skip to content

Commit e817ded

Browse files
committed
bug fixes
1 parent 96b39c5 commit e817ded

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/checkpatchProvider.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,14 @@ export default class CheckpatchProvider implements vscode.CodeActionProvider {
7777
// testing given configuration:
7878
var re = /total: \d* errors, \d* warnings,( \d* checks,)? \d* lines checked/g;
7979
let args = this.linterConfig.args.slice();
80-
let cwd = vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders[0].name : undefined;
80+
let cwd = vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders[0].uri.fsPath : undefined;
8181
args.push('--no-tree - ');
8282
let childProcess = cp.spawnSync(this.linterConfig.path, args, {shell: true, input: ' ', cwd: cwd });
83-
if (childProcess.pid && re.test(childProcess.stdout.toString())) {
83+
if (childProcess.pid && childProcess.stdout && re.test(childProcess.stdout.toString())) {
8484
// all good
8585
} else {
8686
vscode.window.showErrorMessage(
8787
`Checkpatch: calling '${this.linterConfig.path}' failed, please check checkpatch.checkpatchPath and checkpatch.checkpatchPath configutations.`);
88-
console.log(`Checkpatch: '${this.linterConfig.path}' '${args}'`)
8988
if (childProcess.stderr)
9089
console.log(`Checkpatch: '${childProcess.stderr.toString()}'`)
9190
return;
@@ -103,9 +102,9 @@ export default class CheckpatchProvider implements vscode.CodeActionProvider {
103102

104103
private parseCheckpatchLog(log: string, basePath: string): number {
105104
const dictionary: { [fileUri: string]: vscode.Diagnostic[] } = {};
106-
107105
var re = /(WARNING|ERROR|CHECK): ?(.+):(.+)?(?:\n|\r\n|)#\d+: FILE: (.*):(\d+):/g;
108106
var matches;
107+
109108
while (matches = re.exec(log)) {
110109
let type = matches[2];
111110
let message = matches[3];
@@ -143,7 +142,7 @@ export default class CheckpatchProvider implements vscode.CodeActionProvider {
143142

144143
let log = '';
145144
let args = this.linterConfig.args.slice();
146-
let cwd = vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders[0].name : undefined;
145+
let cwd = vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders[0].uri.fsPath : undefined;
147146
args.push('--show-types -f');
148147
args.push(textDocument.fileName.replace(/\\/g, '/'));
149148

0 commit comments

Comments
 (0)