diff options
Diffstat (limited to 'script')
-rw-r--r-- | script/config.lua | 3 | ||||
-rw-r--r-- | script/core/type-hint.lua | 2 | ||||
-rw-r--r-- | script/provider/provider.lua | 35 |
3 files changed, 23 insertions, 17 deletions
diff --git a/script/config.lua b/script/config.lua index 1711052f..dcae15b4 100644 --- a/script/config.lua +++ b/script/config.lua @@ -154,6 +154,9 @@ local ConfigTemplate = { color = { mode = {'Semantic', String}, }, + typeHint = { + enable = {true, Boolean}, + }, intelliSense = { searchDepth = {0, Integer}, }, diff --git a/script/core/type-hint.lua b/script/core/type-hint.lua index ef2d7d08..9e717f14 100644 --- a/script/core/type-hint.lua +++ b/script/core/type-hint.lua @@ -33,7 +33,7 @@ return function (uri, start, finish) end edits[#edits+1] = { newText = (':%s'):format(infer), - start = src.finish, + start = src.finish + 1, finish = src.finish, } end) diff --git a/script/provider/provider.lua b/script/provider/provider.lua index 6c042f7a..be9b6fc9 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -736,23 +736,26 @@ proto.on('$/didChangeVisibleRanges', function (params) end -- compute type-hint - for _, range in ipairs(params.ranges) do - local start, finish = files.unrange(uri, range) - local piece = typeHint(uri, start, finish) - if piece then - for _, edit in ipairs(piece) do - edits[#edits+1] = { - newText = edit.newText, - range = files.range(uri, edit.start, edit.finish) - } + if config.config.typeHint.enable then + local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_TYPE_HINT, 0.5) + for _, range in ipairs(params.ranges) do + local start, finish = files.unrange(uri, range) + local piece = typeHint(uri, start, finish) + if piece then + for _, edit in ipairs(piece) do + edits[#edits+1] = { + newText = edit.newText, + range = files.range(uri, edit.start, edit.finish) + } + end end end + if #edits == 0 then + return + end + proto.notify('$/typeHint', { + uri = uri, + edits = edits, + }) end - if #edits == 0 then - return - end - proto.notify('$/typeHint', { - uri = uri, - edits = edits, - }) end) |