sublimelsp / LSP

Client implementation of the Language Server Protocol for Sublime Text
https://lsp.sublimetext.io/
MIT License
1.66k stars 183 forks source link

remove unnecessary use of generators for session retrieval #2524

Closed rchl closed 1 month ago

rchl commented 1 month ago

Use of generators for retrieving the session is IMO completely unnecessary (correct me if I'm missing something).

  1. This is not an expensive operation that would benefit from being interrupted early. Getting all sessions and returning a list is not gonna be slower. It will potentially even be faster as I imagine that generators have some overhead.
  2. Passing generators around can lead to errors or at least confusion since the values can only be retrieved once from it. In cases like https://github.com/sublimelsp/LSP/blob/603632ea703d6296348680890859c148ac85229a/plugin/core/registry.py#L24-L33 where we pass generators and disguise it as Iterable[Session], there is no way of knowing that the code will fail if trying to iterate sessions twice.