This situation is probably pretty specific, but I’m trying to implement one of the custom Metals LSP extensions
metals/slowTask. It’s similar to the native progress one, but existed before progress was a thing, we use it a bit differently, and it’s cancelable. The idea would be that when a long running task starts, a
metals/slowTask request gets sent it. This request asks the client to display to the user that a long running task is going on, and it gives them the chance to cancel it until the task is complete (completed by a
$/cancelRequest notification from the server).
My initial thought was that when the
metals/slowTask request came in, I’d show the message that it contains in the users status bar (using the
metals/status that is already implemented) with a message suffix of like (“cancelable”) or something. Then there would be a function that a user could just map that could cancel it until the task has been completed, or if it’s a task that for some reason is taking way longer than expected. This is particularly useful when our users are using worksheets and trying stuff out, and accidentally can cause an infinite loop or something.
However, from playing/reading around I don’t really have a clue how to implement a cancelable with the currently handlers setup. As far as I know they are blocking so if I would just continuously want to display something until it completes or until a user cancels it, is there a way to do this without blocking? Any advice on where to look or how to approach this would be super helpful.