Closed pbodnar closed 4 months ago
Working on a fix to keep them organized alphabetically via the UI side. If you have other clients that want them pre-sorted, please open a bug on rsp-server or on the other extensions ;)
@robstryker, thank you for the quick fix, I hope it is good enough for now! :)
Problem
Right now, when you add new servers into the Servers view, they are simply put to the end of the list. On the VS Code restart though, their order is randomized.
I've tracked the cause of this problem down to the
rsp-server
project, where the server instances that are returned to the UI on startup via/getServerHandles
are A) kept in a plainHashMap
, B) loaded from the file system viajava.io.File#listFiles()
- see ServerModel.java. Both A and B on their own can cause the list being randomly shuffled.Solution?
I think the "best" solution would be to let the users order their servers as they like, but that would require extending the data model (there is no notion of ordering so far) and to implement corresponding UI actions.
A "good-enough" solution could be to at least sort the servers by their label ("Server Name" in the New Server wizard; stored as
id
in the underlying model; BTW one cannot change the server name later on, because theid
is immutable and used for the name of the file holding the server JSON definition). Not sure whether to do this on the server, or on the client (UI) side. Doing it in the UI could be probably preferable, as we can control it "more closely" there and possibly improve it in the future?Apart from this, I think it wouldn't break anything if
LinkedHashMap
was used instead ofHashMap
on the server side, so that at least the servers are kept in insertion order there.Note that I'm new to the code base of these projects, so I won't be surprised if someone comes with some better approach... :)