[gnome-builder: 1/4] LSP: Don't send messages while waiting to be 'initialized'
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder: 1/4] LSP: Don't send messages while waiting to be 'initialized'
- Date: Fri, 19 Feb 2021 19:58:29 +0000 (UTC)
commit f24fb86fb72396bfaccacfed2e7dfee901213cae
Author: peter <blackwolf12333 gmail com>
Date: Thu Feb 18 13:54:02 2021 +0100
LSP: Don't send messages while waiting to be 'initialized'
The language server protocol specifies:
Until the server has responded to the initialize request
with an InitializeResult, the client must not send any
additional requests or notifications to the server.
as well as:
The initialized notification is sent from the client to
the server after the client received the result of the
initialize request but before the client is sending any
other request or notification to the server.
The implementation of the client side in libide did not
conform to this specification and let messages be send
to the server while we had not received the 'initialize'
response, and before we responded ourselves with 'initialized'.
src/libide/lsp/ide-lsp-client.c | 9 +++++++++
1 file changed, 9 insertions(+)
---
diff --git a/src/libide/lsp/ide-lsp-client.c b/src/libide/lsp/ide-lsp-client.c
index 0af69fa03..cdaf303a8 100644
--- a/src/libide/lsp/ide-lsp-client.c
+++ b/src/libide/lsp/ide-lsp-client.c
@@ -52,6 +52,7 @@ typedef struct
GVariant *server_capabilities;
IdeLspTrace trace;
gchar *root_uri;
+ gboolean initialized;
} IdeLspClientPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (IdeLspClient, ide_lsp_client, IDE_TYPE_OBJECT)
@@ -1244,6 +1245,7 @@ ide_lsp_client_init (IdeLspClient *self)
priv->trace = IDE_LSP_TRACE_OFF;
priv->languages = g_ptr_array_new_with_free_func (g_free);
+ priv->initialized = FALSE;
priv->diagnostics_by_file = g_hash_table_new_full ((GHashFunc)g_file_hash,
(GEqualFunc)g_file_equal,
@@ -1324,6 +1326,8 @@ ide_lsp_client_initialized_cb (GObject *object,
project = ide_project_from_context (context);
dzl_signal_group_set_target (priv->project_signals, project);
+ priv->initialized = TRUE;
+
g_signal_emit (self, signals[INITIALIZED], 0);
IDE_EXIT;
@@ -1691,6 +1695,11 @@ ide_lsp_client_call_async (IdeLspClient *self,
G_IO_ERROR,
G_IO_ERROR_NOT_CONNECTED,
"No connection to language server");
+ else if (!priv->initialized)
+ ide_task_return_new_error (task,
+ G_IO_ERROR,
+ G_IO_ERROR_NOT_CONNECTED,
+ "Server is not ready yet");
else
jsonrpc_client_call_async (priv->rpc_client,
method,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]