From 26b94c16676c6e813ffc75aef4efccb4a25145d1 Mon Sep 17 00:00:00 2001 From: Arcanox Date: Sat, 25 Sep 2021 18:01:40 -0500 Subject: Fix semantic token highlighting not working after the "newparser" changes recently merged into master --- script/provider/provider.lua | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'script/provider/provider.lua') diff --git a/script/provider/provider.lua b/script/provider/provider.lua index 070652ef..9803801b 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -688,11 +688,7 @@ proto.on('textDocument/semanticTokens/full', function (params) workspace.awaitReady() local _ = progress.create(lang.script.WINDOW_PROCESSING_SEMANTIC_FULL, 0.5) local core = require 'core.semantic-tokens' - local text = files.getText(uri) - if not text then - return nil - end - local results = core(uri, 0, #text) + local results = core(uri, 0, math.huge) return { data = results } @@ -706,15 +702,7 @@ proto.on('textDocument/semanticTokens/range', function (params) workspace.awaitReady() local _ = progress.create(lang.script.WINDOW_PROCESSING_SEMANTIC_RANGE, 0.5) local core = require 'core.semantic-tokens' - local cache = files.getOpenedCache(uri) - local start, finish - if cache and not cache['firstSemantic'] then - cache['firstSemantic'] = true - start = 0 - finish = #files.getText(uri) - else - start, finish = converter.unpackRange(uri, params.range) - end + local start, finish = converter.unpackRange(uri, params.range) local results = core(uri, start, finish) return { data = results -- cgit v1.2.3 From 107f9a05ca4969a6f376180a03e8287240ea6d36 Mon Sep 17 00:00:00 2001 From: Arcanox Date: Sun, 26 Sep 2021 00:01:26 -0500 Subject: Semantic highlighting methods cannot return a null response if they're canceled or the editor will clear all the tokens until the next time the request returns a full result --- script/provider/provider.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'script/provider/provider.lua') diff --git a/script/provider/provider.lua b/script/provider/provider.lua index 9803801b..05202c01 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -692,7 +692,7 @@ proto.on('textDocument/semanticTokens/full', function (params) return { data = results } -end) +end, true) proto.on('textDocument/semanticTokens/range', function (params) local uri = params.textDocument.uri @@ -707,7 +707,7 @@ proto.on('textDocument/semanticTokens/range', function (params) return { data = results } -end) +end, true) proto.on('textDocument/foldingRange', function (params) local core = require 'core.folding' -- cgit v1.2.3 From b8feb6626cd4caefba683eaf4f99ca0600aab950 Mon Sep 17 00:00:00 2001 From: Arcanox Date: Sun, 26 Sep 2021 14:49:55 -0500 Subject: Put back thing that I didn't mean to commit --- script/provider/provider.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'script/provider/provider.lua') diff --git a/script/provider/provider.lua b/script/provider/provider.lua index 05202c01..7a5ce558 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -702,7 +702,15 @@ proto.on('textDocument/semanticTokens/range', function (params) workspace.awaitReady() local _ = progress.create(lang.script.WINDOW_PROCESSING_SEMANTIC_RANGE, 0.5) local core = require 'core.semantic-tokens' - local start, finish = converter.unpackRange(uri, params.range) + local cache = files.getOpenedCache(uri) + local start, finish + if cache and not cache['firstSemantic'] then + cache['firstSemantic'] = true + start = 0 + finish = #files.getText(uri) + else + start, finish = converter.unpackRange(uri, params.range) + end local results = core(uri, start, finish) return { data = results -- cgit v1.2.3 From 17d2ae286db1b8c8484e5db5bc3c13a25b2426bb Mon Sep 17 00:00:00 2001 From: Arcanox Date: Sun, 26 Sep 2021 14:50:36 -0500 Subject: Change the way canceled semanticToken requests are handled according to @sumneko's suggestion --- script/provider/provider.lua | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'script/provider/provider.lua') diff --git a/script/provider/provider.lua b/script/provider/provider.lua index 7a5ce558..632dae6f 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -680,11 +680,13 @@ proto.on('workspace/symbol', function (params) end) -proto.on('textDocument/semanticTokens/full', function (params) +proto.on('textDocument/semanticTokens/full', function (params, id) local uri = params.textDocument.uri await.close('textDocument/semanticTokens/full') await.setID('textDocument/semanticTokens/full') - await.setID('update:' .. uri) + await.setID('update:' .. uri, function() + proto.close(id, define.ErrorCodes.ContentModified) + end) workspace.awaitReady() local _ = progress.create(lang.script.WINDOW_PROCESSING_SEMANTIC_FULL, 0.5) local core = require 'core.semantic-tokens' @@ -692,13 +694,15 @@ proto.on('textDocument/semanticTokens/full', function (params) return { data = results } -end, true) +end) -proto.on('textDocument/semanticTokens/range', function (params) +proto.on('textDocument/semanticTokens/range', function (params, id) local uri = params.textDocument.uri await.close('textDocument/semanticTokens/range') await.setID('textDocument/semanticTokens/range') - await.setID('update:' .. uri) + await.setID('update:' .. uri, function() + proto.close(id, define.ErrorCodes.ContentModified) + end) workspace.awaitReady() local _ = progress.create(lang.script.WINDOW_PROCESSING_SEMANTIC_RANGE, 0.5) local core = require 'core.semantic-tokens' @@ -715,7 +719,7 @@ proto.on('textDocument/semanticTokens/range', function (params) return { data = results } -end, true) +end) proto.on('textDocument/foldingRange', function (params) local core = require 'core.folding' -- cgit v1.2.3 From 55e30e88ba33a28acc53265b249860b0bbc06fba Mon Sep 17 00:00:00 2001 From: Arcanox Date: Sun, 26 Sep 2021 15:04:14 -0500 Subject: Revert changes related to canceled requests --- script/provider/provider.lua | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'script/provider/provider.lua') diff --git a/script/provider/provider.lua b/script/provider/provider.lua index 632dae6f..6373fe7e 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -680,13 +680,11 @@ proto.on('workspace/symbol', function (params) end) -proto.on('textDocument/semanticTokens/full', function (params, id) +proto.on('textDocument/semanticTokens/full', function (params) local uri = params.textDocument.uri await.close('textDocument/semanticTokens/full') await.setID('textDocument/semanticTokens/full') - await.setID('update:' .. uri, function() - proto.close(id, define.ErrorCodes.ContentModified) - end) + await.setID('update:' .. uri) workspace.awaitReady() local _ = progress.create(lang.script.WINDOW_PROCESSING_SEMANTIC_FULL, 0.5) local core = require 'core.semantic-tokens' @@ -696,13 +694,11 @@ proto.on('textDocument/semanticTokens/full', function (params, id) } end) -proto.on('textDocument/semanticTokens/range', function (params, id) +proto.on('textDocument/semanticTokens/range', function (params) local uri = params.textDocument.uri await.close('textDocument/semanticTokens/range') await.setID('textDocument/semanticTokens/range') - await.setID('update:' .. uri, function() - proto.close(id, define.ErrorCodes.ContentModified) - end) + await.setID('update:' .. uri) workspace.awaitReady() local _ = progress.create(lang.script.WINDOW_PROCESSING_SEMANTIC_RANGE, 0.5) local core = require 'core.semantic-tokens' -- cgit v1.2.3