Skip to content

Commit 1e29666

Browse files
authored
fix(SchemaTree): snippet not insert if user is not on Query tab (#1766)
1 parent 1f8d6fc commit 1e29666

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/utils/monaco/insertSnippet.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
1-
export function insertSnippetToEditor(input: string) {
2-
if (!window.ydbEditor) {
1+
export async function insertSnippetToEditor(input: string) {
2+
let retry = 1;
3+
4+
const checkEditor = async () => {
5+
if (!window.ydbEditor) {
6+
if (retry) {
7+
await new Promise((r) => {
8+
window.setTimeout(r, 100);
9+
});
10+
retry -= 1;
11+
checkEditor();
12+
} else {
13+
return false;
14+
}
15+
}
16+
return true;
17+
};
18+
const editor = await checkEditor();
19+
if (!editor) {
320
console.error('Monaco editor not found');
21+
return;
422
}
23+
524
window.ydbEditor?.trigger(undefined, 'insertSnippetToEditor', input);
625
}

0 commit comments

Comments
 (0)