Skip to content

Commit

Permalink
修复:第三方接口文档中的table没有fields字段时,导致的补全异常;修复:因为脚本存在语法错误,保存时自动format导致异常日志弹出
Browse files Browse the repository at this point in the history
  • Loading branch information
liwangqian committed Oct 9, 2018
1 parent 6c43443 commit 813b8a3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion server/lib/engine/extend.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function parseJsonObject(node, name) {

function parseTableJsonObject(node, name) {
let table = new LuaTable();
table._fields = parseJsonObject(node.fields);
table._fields = parseJsonObject(node.fields) || [];
table._metatable = parseJsonObject(node.metatable, '__mt');
table.description = node.description;
table.link = node.link;
Expand Down
9 changes: 6 additions & 3 deletions server/providers/format-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ class FormatProvider {
text = text.substring(document.offsetAt(range.start), document.offsetAt(range.end));
}

let formattedText = fmt.formatText(text, this._formatOptions(opt));

return [langserver.TextEdit.replace(range, formattedText)];
try {
let formattedText = fmt.formatText(text, this._formatOptions(opt));
return [langserver.TextEdit.replace(range, formattedText)];
} catch (err) {
return [];
}
});
}

Expand Down

0 comments on commit 813b8a3

Please sign in to comment.