Skip to content

Commit

Permalink
fix(SchemaTree): snippet not insert if user is not on Query tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Raubzeug committed Dec 18, 2024
1 parent 27f9a9f commit 11b8eee
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/utils/monaco/insertSnippet.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
export function insertSnippetToEditor(input: string) {
if (!window.ydbEditor) {
export async function insertSnippetToEditor(input: string) {
let retry = 1;

const checkEditor = async () => {
if (!window.ydbEditor) {
if (retry) {
await new Promise((r) => {
window.setTimeout(r, 100);
});
retry -= 1;
checkEditor();
} else {
return false;
}
}
return true;
};
const editor = await checkEditor();
if (!editor) {
console.error('Monaco editor not found');
return;
}

window.ydbEditor?.trigger(undefined, 'insertSnippetToEditor', input);
}

0 comments on commit 11b8eee

Please sign in to comment.