Skip to content

Commit

Permalink
fix errors when open a file without .lua extension, see issue #3.
Browse files Browse the repository at this point in the history
  • Loading branch information
liwangqian committed Nov 14, 2017
1 parent cb12e01 commit a74f192
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

All notable changes to the "luacoderassist" extension will be documented in this file.

### 1.2.7
- fix errors when open a file without `.lua` extension, see issue #3.

### 1.2.6
- fix errors when open a file which has syntax error.
- add `keepAfterClosed` option for luacheck diagnostics.
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ This extension contributes the following settings:

## Release Notes

### 1.2.7
- fix errors when open a file without `.lua` extension, see issue #3.

### 1.2.6
- fix errors when open a file which has syntax error.
- add `keepAfterClosed` option for luacheck diagnostics.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "LuaCoderAssist",
"description": "lua coder assistant in javascript for vscode",
"icon": "images/icon.png",
"version": "1.2.6",
"version": "1.2.7",
"publisher": "liwangqian",
"engines": {
"vscode": "^1.11.0"
Expand Down
7 changes: 5 additions & 2 deletions server/lib/symbol/walker.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ class Walker {
this.reset();
this.document.uri = uri;
this.document.ast = ast;
let fileName = uri.match(/(\w+)\.lua$/)[1];
this.walkNodes(ast.body, {name: '_G'}, utils.loc2Range(ast.loc), {name: fileName, bases: []}, true);
let matches = uri.match(/(\w+)(\.lua)?$/);
if (matches) {
let fileName = matches[1];
this.walkNodes(ast.body, { name: '_G' }, utils.loc2Range(ast.loc), { name: fileName, bases: [] }, true);
}

return this.document;
}
Expand Down
4 changes: 4 additions & 0 deletions server/providers/lib/linters.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ class Luacheck {
return diagnostics;
}

if (data.stdout === undefined) {
return diagnostics;
}

let maxProblems = this.coder.settings.luacheck.maxProblems;

//luacheck output to stdout channal
Expand Down

0 comments on commit a74f192

Please sign in to comment.