How to make a request few seconds after the user stop typing and update source code?
Hey guys, We're creating a plug-in that gets code suggestion from a micro service (API) based on user request (like Github copilot, but for an specific niche of application). If the user types: # read excel file sorting by date descending The plug-in injects a code snippet for that purpose. It's working, we are using TypedHandlerDelegate to monitor the file and make the request and update the code. But our plug-in is making a request at each typed key. It would be better to wait the user to stop typing the key after a few milliseconds or making requests in some intervals. What we would like to do: - use a thread to avoid making lot of requests (make a request after a few keys typed or after some time). Is there a way to keep a thread running in the background that is able to write (add snippet) into the source code file? Is there a way to schedule a thread (write privileges) to run after some time? (2 seconds after a key/event happened) Any suggestion of a better approach?
Please sign in to leave a comment.
Hi there, I implements a similiar delay trigger function in my Notes plugin(https://plugins.jetbrains.com/plugin/17501-notes), the code is just simple and easy to use, and here I grant the rights for you to use this code in any projects: