From b359ed230eda1cbe4e7e47df8e5b0b588970721b Mon Sep 17 00:00:00 2001 From: Heyward Fann Date: Tue, 26 Nov 2024 11:57:02 +0800 Subject: [PATCH] feat(semanticTokens): decrease highlighting range From [start-height*1.5, end+height*1.5] to [start-height/2, end+height/2], decrease items to highlight Related #5199, should reduce flickering happened --- src/__tests__/handler/semanticTokens.test.ts | 4 ++-- src/handler/semanticTokens/buffer.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/__tests__/handler/semanticTokens.test.ts b/src/__tests__/handler/semanticTokens.test.ts index 0eb5578c3d1..6b4486ad677 100644 --- a/src/__tests__/handler/semanticTokens.test.ts +++ b/src/__tests__/handler/semanticTokens.test.ts @@ -317,13 +317,13 @@ describe('semanticTokens', () => { await item.onCursorMoved() await helper.waitValue(async () => { let markers = await buf.getExtMarks(ns, 0, -1, { details: true }) - return markers.length > 300 + return markers.length > 100 }, true) nvim.command('normal! 200G', true) await item.onCursorMoved() await helper.waitValue(async () => { let markers = await buf.getExtMarks(ns, 0, -1, { details: true }) - return markers.length > 500 + return markers.length > 200 }, true) }) diff --git a/src/handler/semanticTokens/buffer.ts b/src/handler/semanticTokens/buffer.ts index 5d497579eae..0330e0332bf 100644 --- a/src/handler/semanticTokens/buffer.ts +++ b/src/handler/semanticTokens/buffer.ts @@ -389,8 +389,8 @@ export default class SemanticTokensBuffer implements SyncItem { let height = workspace.env.lines spans.forEach(o => { let s = o[0] - o[0] = Math.max(0, Math.floor(s - height * 1.5)) - o[1] = Math.min(lineCount, Math.ceil(o[1] + height * 1.5), s + height * 2) + o[0] = Math.max(0, Math.floor(s - height / 2)) + o[1] = Math.min(lineCount, Math.ceil(o[1] + height / 2), s + height / 2) }) for (let [start, end] of Regions.mergeSpans(spans)) { if (!skipCheck && regions.has(start, end)) continue