summaryrefslogtreecommitdiff
path: root/script/core/code-action.lua
diff options
context:
space:
mode:
Diffstat (limited to 'script/core/code-action.lua')
-rw-r--r--script/core/code-action.lua16
1 files changed, 12 insertions, 4 deletions
diff --git a/script/core/code-action.lua b/script/core/code-action.lua
index 4eb21ff8..1e19d466 100644
--- a/script/core/code-action.lua
+++ b/script/core/code-action.lua
@@ -624,24 +624,32 @@ local function checkJsonToLua(results, uri, start, finish)
end
local startOffset = guide.positionToOffset(state, start)
local finishOffset = guide.positionToOffset(state, finish)
- local jsonStart = text:match('()[%{%[]', startOffset + 1)
+ local jsonStart = text:match('()["%{%[]', startOffset + 1)
if not jsonStart then
return
end
- local jsonFinish
+ local jsonFinish, finishChar
for i = math.min(finishOffset, #text), jsonStart + 1, -1 do
local char = text:sub(i, i)
if char == ']'
or char == '}' then
jsonFinish = i
+ finishChar = char
break
end
end
if not jsonFinish then
return
end
- if not text:sub(jsonStart, jsonFinish):find '"%s*%:' then
- return
+ if finishChar == '}' then
+ if not text:sub(jsonStart, jsonFinish):find '"%s*%:' then
+ return
+ end
+ end
+ if finishChar == ']' then
+ if not text:sub(jsonStart, jsonFinish):find ',' then
+ return
+ end
end
results[#results+1] = {
title = lang.script.ACTION_JSON_TO_LUA,