Skip to content

Commit

Permalink
fix: wait longer for cursor to move to the correct line in .d.ts (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
ascott18 authored Apr 2, 2023
1 parent fdcd582 commit f1878f4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ export function activate() {
return

// wait for e.selection to update (init 0)
await Promise.resolve()
const waitInterval = 5
const maxWait = 1000
for (let i = 0; i < maxWait; i += waitInterval) {
await new Promise(resolve => setTimeout(resolve, waitInterval))
if (e.selection.anchor.line !== 0)
break
}

const line = e.document.lineAt(e.selection.anchor.line)
const text = line.text
Expand Down

0 comments on commit f1878f4

Please sign in to comment.