Skip to content

Commit

Permalink
feat(semanticTokens): decrease highlighting range
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fannheyward committed Nov 26, 2024
1 parent aacbbca commit b359ed2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/__tests__/handler/semanticTokens.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})

Expand Down
4 changes: 2 additions & 2 deletions src/handler/semanticTokens/buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b359ed2

Please sign in to comment.