From f1878f486c8841c0484aee451fcf6bd75e05378c Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Sun, 2 Apr 2023 05:27:20 -0700 Subject: [PATCH] fix: wait longer for cursor to move to the correct line in .d.ts (#7) --- src/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index a991e01..e46a36f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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