Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions content.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ const mainProcess = async () => {

if (suggestion) {
clearInterval(animationInterval)
// cancel animation element
// cancel animation element
inputElement.classList.remove('before-content')

isRequestSuccessful = true
Expand All @@ -505,10 +505,12 @@ const mainProcess = async () => {
// Replace the content of the text animation box with code
animationElement.innerHTML = suggestion
}
}
}

}
};

// Automatic request timer
let autoRequestTimeout;
const montedEventListener = () => {
document.addEventListener('keydown', async (event) => {
// Check if the Ctrl + Space keys were pressed
Expand All @@ -519,15 +521,38 @@ const montedEventListener = () => {
if (isRequestInProgress || isRequestSuccessful) {
return
}

await mainProcess()

}

});
document.addEventListener('keydown', addFillCodeKeyListener);

// '[', '{', ''','"' are invalid because of codemirror default event, did not find how to stop
document.addEventListener('input', async (event) => {

// If there is no code hint
if (document.querySelectorAll(".per-insert-code").length == 0) {
isRequestSuccessful = false
}

if (isRequestInProgress || isRequestSuccessful) {
return
}

if (autoRequestTimeout) {
clearTimeout(autoRequestTimeout);
}

// Set a new timeout for 0.8 seconds. After my test, the 0.8s delay is the most user-friendly
autoRequestTimeout = setTimeout(async () => {
await mainProcess()
}, 800);

})
}



// Two options 'lab' and 'notebook'
let currctJupyterModel = {}

Expand Down