summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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', {