-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TSServer #91
Comments
Code Review:
|
Final opinions ( @park9140 / @csnover ). Recommend we don't use TSServer
Good stuff we should pull in:
|
Make sure that the TypeScript team receives this feedback, if the server doesn’t work for atom-typescript it probably won’t work for other people that want to use it too. I don’t understand what you are saying about “full” bidirectional communication or “doesn’t support two way”, so it would be useful for me if you could explain exactly what that means and why you think the tsserver communication model doesn’t work. |
Command -> response is only client -> server -> client. There is no server -> client -> server mechanism. There is however a server -> client mechanism (called event) which is one way first and forget. This isn't a big blocker though. But we use it here : https://github.com/TypeStrong/atom-typescript/blob/master/lib/main/lang/projectService.ts#L88-L93 |
The real blocker is just that the server abstracts away the language service and only gives us Object bags and not Class instances, it really can't do that easily over stdout. The class instances only exist in the worker (true in our case as well) but since we wrote the worker we can extend it with new stuff whereas if we use the TSServer worker (called the server) we can't extend the worker. TSServer is really just a reference implementation of a worker. I'll raise an issue with the TypeScript team right now. |
My current thinking is that the server shouldn’t be querying the client for information like that; it should be a unidirectional model. The server lets the client know when an event happens and then if the client needs to change something in the server it can do it through the normal request/response channel. This makes operations non-atomic, but, it probably isn’t a big deal. Otherwise, the server starts mandating that a client implement certain operations, which doesn’t seem right. Does that make sense, or am I not thinking of something correctly? |
Oh, and with regards to the missing types, is this really an issue? I would expect the client just implements a reduced subset of types anyway that expose API that’s good for the client itself. |
We are big fans of atom-typescript. It's the kind of great tooling we had in mind when we built the language service. The protocol-based system is there for editors, like Emacs and Sublime, that do not have native JavaScript. As you point out, the snapshot system and watch code is to reduce requirements on plug-ins. Makes sense to use the broader language service and compiler APIs when editor has native JavaScript, especially with a project as ambitious as atom-typescript. |
I agree completely. But having that ability of two way communication made it easier to write (potentially bad in that its strongly coupled) simple code to just fetch the data it needs. Like I said it could be refactored later and not really a blocker. @steveluc thanks for the clarification ❤️ will keep going as planned. |
Seems like we should really rely on as much from core as possible. In this case however we definitely need more access. Looking through the way things are done we can do way better efficiency wise by implementing the language service script snapshots for open files on top of changes sent by the editor rather than tracking by file watches where we need to parse for diffs in order to get change sets. As far as I can see we actually need to do this in order to get live edit efficiency for things like format on keystroke to work. |
We definitely need to do diffs for open files as you've mentioned but we do need |
We have a new milestone : https://github.com/TypeStrong/atom-typescript/milestones/5%20TSServer |
:) it has been known to happen. |
FWIW with Sublime and Emacs, we do our best to send individual diffs (location, deleted length, inserted string) to the server. Emacs gives us diffs for every change. ST3 gives us on_text_command, on_modified, and on_post_text_command. However, for example, none of these are called on undo/redo. Sometimes only on_modified is called, usually for the insert command. ST3 also has view.change_count(), which is incremented after undo. ST2 gives less information and so more buffer chunks need to be sent. For large files, sending the individual changes leads to significantly smoother performance. |
Keep an eye on microsoft/TypeScript#2041
Might significantly reduce the amount of architecture we need to maintain.
The text was updated successfully, but these errors were encountered: