3 ms·
I don't know about you, but I do not want to block on every keystroke. Program analysis can take time, asynchronous feedback is a natural fit. None of the featu
by ablob 7d ago
I don't know about you, but I do not want to block on every keystroke.
Program analysis can take time, asynchronous feedback is a natural fit.
None of the features I use from LSP should be synchronous.
I can almost guarantee you that a synchronous API would yield a much more complicated design just because many operations can not be expected to reliably work within a few milliseconds.
You want to rename something across multiple files? Well now you add file system overhead and blow straight past reliable frame timings. Good luck waiting for that operation to finish. Of course you could make the API beginRename, and queryRename, or whatever you fancy to see if the operation was successful, but now you're back to what you wanted to avoid: an asynchronous API.
Do mind that the example is actually one of the better cases, as many things you might want to do with a codebase are actually more expensive.
You will feel the hiccups from waiting in the UI thread and you will loathe the program for it.
- mitxela 7d agoWhy do you assume renaming must be completed when Rename returns? Rather, the LSP must have a consisten snapshot when AboutToSaveFile returns.
- ablob 7d agoI assume that the result of the rename operation must be known. I.e. if it was successful or not, or which files were affected. That implies 2 function calls. One to start the operation, and one to query its result. That is, by definition, already an asynchronous interface. The only other (i.e. synchonous) way to achieve remote procedure calls is by blocking until it's finished.
- mitxela 6d agoIf you insist on showing the result of a rename on the next frame, then yes, it must block the next frame until it's done. Would you write your editor that way if it didn't use LSP but was specific to one language? If not, but you would write it that way with a language plugin, why? You still have to write a good product. You can't blame the plugin API for everything you get wrong.