summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsumneko <sumneko@hotmail.com>2021-10-16 16:48:50 +0800
committersumneko <sumneko@hotmail.com>2021-10-16 16:48:50 +0800
commit88d38d4f360346e7d3cb4bb2687d01b1adac7a7e (patch)
tree32dd92071e6ecf05f0ee10a477301bc8b7294ea0
parent577c52bb980007c03fae7f04d38c46dd256094d7 (diff)
downloadlua-language-server-88d38d4f360346e7d3cb4bb2687d01b1adac7a7e.zip
fix `json to lua`
-rw-r--r--script/core/command/jsonToLua.lua8
1 files changed, 6 insertions, 2 deletions
diff --git a/script/core/command/jsonToLua.lua b/script/core/command/jsonToLua.lua
index 8a493b5e..6aecee2c 100644
--- a/script/core/command/jsonToLua.lua
+++ b/script/core/command/jsonToLua.lua
@@ -5,13 +5,17 @@ local proto = require 'proto'
local define = require 'proto.define'
local lang = require 'language'
local converter = require 'proto.converter'
+local guide = require 'parser.guide'
return function (data)
- local text = files.getText(data.uri)
+ local state = files.getState(data.uri)
+ local text = files.getText(data.uri)
if not text then
return
end
- local jsonStr = text:sub(data.start, data.finish)
+ local start = guide.positionToOffset(state, data.start)
+ local finish = guide.positionToOffset(state, data.finish)
+ local jsonStr = text:sub(start + 1, finish)
local suc, res = pcall(json.decode, jsonStr)
if not suc then
proto.notify('window/showMessage', {