Commit b993e563 authored by Günther Wagner's avatar Günther Wagner
Browse files

lsp: fixed lsp notifications if multiple requests happening

parent 49613311
Pipeline #185493 failed with stage
in 3 minutes and 18 seconds
...@@ -750,13 +750,14 @@ ide_lsp_client_real_notification (IdeLspClient *self, ...@@ -750,13 +750,14 @@ ide_lsp_client_real_notification (IdeLspClient *self,
} }
else if (g_str_equal (method, "$/progress")) else if (g_str_equal (method, "$/progress"))
{ {
gboolean notification_exists = FALSE;
const gchar *token = NULL; const gchar *token = NULL;
const gchar *message = NULL; const gchar *message = NULL;
const gchar *title = NULL; const gchar *title = NULL;
const gchar *kind = NULL; const gchar *kind = NULL;
IdeContext *context; IdeContext *context;
IdeNotifications *notifications; IdeNotifications *notifications;
IdeNotification *notification; IdeNotification *notification = NULL;
JSONRPC_MESSAGE_PARSE (params, "token", JSONRPC_MESSAGE_GET_STRING (&token), JSONRPC_MESSAGE_PARSE (params, "token", JSONRPC_MESSAGE_GET_STRING (&token),
"value", "{", "value", "{",
...@@ -770,26 +771,36 @@ ide_lsp_client_real_notification (IdeLspClient *self, ...@@ -770,26 +771,36 @@ ide_lsp_client_real_notification (IdeLspClient *self,
"}"); "}");
context = ide_object_get_context (IDE_OBJECT (self)); context = ide_object_get_context (IDE_OBJECT (self));
notifications = ide_object_get_child_typed (IDE_OBJECT (context), IDE_TYPE_NOTIFICATIONS); notifications = ide_object_get_child_typed (IDE_OBJECT (context), IDE_TYPE_NOTIFICATIONS);
notification = ide_notifications_find_by_id (notifications, token);
if (notification == NULL)
notification_exists = FALSE;
else
notification_exists = TRUE;
if (ide_str_equal0 (kind, "begin")) if (ide_str_equal0 (kind, "begin"))
{ {
notification = ide_notification_new (); if (!notification_exists)
ide_notification_set_id (notification, token); {
ide_notification_set_has_progress (notification, TRUE); notification = ide_notification_new ();
ide_notification_set_progress_is_imprecise (notification, TRUE); ide_notification_set_id (notification, token);
ide_notification_set_has_progress (notification, TRUE);
ide_notification_set_progress_is_imprecise (notification, TRUE);
}
ide_notification_set_title (notification, title); ide_notification_set_title (notification, title);
ide_notification_set_body (notification, message != NULL ? message : title); ide_notification_set_body (notification, message != NULL ? message : title);
ide_notification_attach (notification, IDE_OBJECT (context));
if (!notification_exists)
ide_notification_attach (notification, IDE_OBJECT (context));
} }
else else
{ {
notification = ide_notifications_find_by_id (notifications, token);
if (message != NULL && notification != NULL) if (message != NULL && notification != NULL)
ide_notification_set_body (notification, message); ide_notification_set_body (notification, message);
} }
if (ide_str_equal0 (kind, "end") && notification != NULL) if (ide_str_equal0 (kind, "end") && notification != NULL)
ide_notification_withdraw_in_seconds (notification, 3); ide_notification_withdraw (notification);
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment