LanguageClient icon indicating copy to clipboard operation
LanguageClient copied to clipboard

Allow RestartingServer behavior to be configured

Open jbromberg opened this issue 1 year ago • 3 comments

Would be nice to support behavior for how the RestartingServer restarts.

Currently, there's a 5 second cooldown hardcoded in: https://github.com/ChimeHQ/LanguageClient/blob/253b8a0d2ea2a8c84cbd51dd6931ae0936b1f1f9/Sources/LanguageClient/RestartingServer.swift#L232

Possible idea:

enum RestartBehavior {
    case nextRequest
    case afterCooldown(seconds: Int)
}

jbromberg avatar Jan 17 '24 23:01 jbromberg

This might be worthy of a separate issue, but it may also be helpful to allow a closure to be executed when the server restarts. you may want to send the server a didOpen notification or do some other work.

jbromberg avatar Jan 18 '24 15:01 jbromberg

Can you elaborate on what you want to send the server? Its state should be transparently restored when it is started back up. For example, any open documents are automatically re-opened.

mattmassicotte avatar Jan 18 '24 15:01 mattmassicotte

It seems like open docs are re-opened only when the server state is set to restartNeeded but I don't see anywhere that it would reach this state. When calling connectionInvalidated() the server state gets set to notStarted after 5 seconds which doesn't reopen docs upon reconnecting.

jbromberg avatar Jan 18 '24 15:01 jbromberg